on 2024 Jan 06 4:54 PM
Request clarification before answering.
Hi Kirana Rania,
for example, if the data in Excel looks like the one above, you could test the following:Sub Export()
'If Not IsObject(Application1) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Application1 = SapGuiAuto.GetScriptingEngine
'End If
'If Not IsObject(Connection) Then
Set Connection = Application1.Children(0)
'End If
'If Not IsObject(session) Then
Set session = Connection.Children(0)
'End If '
Dim LastRow
Dim sht As Worksheet
Set sht = ThisWorkbook.Worksheets("sheet1")
LastRow = sht.Range("C2").CurrentRegion.Rows.Count
'sht.Range("C2:C" & LastRow).Copy
sht.Range("B2").Select
For i = 1 To 3
Application.ActiveCell.Offset(0, 1).Range("A1").Select
sht.Range(Selection, Selection.End(xlDown)).Select
Application.Selection.Copy
session.findById("wnd[0]/tbar[0]/okcd").Text = "/NFBL1N"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtKD_BUKRS-LOW").Text = "BK01"
'session.findById("wnd[0]/usr/ctxtKD_BUKRS-LOW").SetFocus
'session.findById("wnd[0]/usr/ctxtKD_BUKRS-LOW").caretPosition = 4
session.findById("wnd[0]/usr/ctxtKD_LIFNR-LOW").Text = ""
session.findById("wnd[0]/usr/btn%_KD_LIFNR_%_APP_%-VALU_PUSH").press
session.findById("wnd[1]/tbar[0]/btn[24]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[1]").Select
session.findById("wnd[1]/usr/cmbG_LISTBOX").SetFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "D:\SAP\Data\"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = sht.Range("A" & CStr(i)).Value
'session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 36
session.findById("wnd[1]/tbar[0]/btn[11]").press
Application.Wait (Now + TimeValue("0:00:05"))
Next i
sht.Range("A1").Select
Application.CutCopyMode = False
session.findById("wnd[0]/tbar[0]/btn[3]").press
End Sub
Regards, ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
11 | |
9 | |
8 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.