Sub invoicenumber1()
Dim SAPGUIAuto As Object '
Dim SAPApplication As Object '
Dim Connection As Object '
Dim session As Object
Set SAPGUIAuto = GetObject("SAPGUI")
Set objGui = SAPGUIAuto.GetScriptingEngine
Set objConn = objGui.Children(0)
Set session = objConn.Children(0)
Dim selectedcountry As String
selectedcountry = ActiveWorkbook.ActiveSheet.Range("D2").Value
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nvl02"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtLIKP-VBELN").Text = selectedcountry
session.findById("wnd[0]/usr/ctxtLIKP-VBELN").caretPosition = 8
session.findById("wnd[0]/tbar[1]/btn[30]").press
session.findById("wnd[0]/usr/shell/shellcont[1]/shell[0]").pressButton "&FIND"
session.findById("wnd[1]/usr/txtLVC_S_SEA-STRING").Text = "invoice"
session.findById("wnd[1]/usr/txtLVC_S_SEA-STRING").caretPosition = 7
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[1]/btn[18]").press
session.findById("wnd[1]/usr/ctxtVBUK-VBELN").caretPosition = 10
End Sub
我想到复制文本从sap到excel请帮助我与这给定的代码
我是这个vba新手
我想从此行复制文本(会话.findById(“wnd[1]/usr/ctxtVBUK-VBELN”).caretPosition = 10)
1条答案
按热度按时间68bkxrlz1#
添加一个监视(在VBA编辑器中选择代码并右键单击-〉添加监视)“(session.findById(“wnd[1]/usr/ctxtVBUK-VBELN”)”,然后您可以看到所有属性,并可以根据需要使用它们