Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Hi! I have been trying to get this macro working in excel but i diont know why it does not work. Where should i input my login info?

do i need to input my login info, since I have auto log in? What changes do I need to do? What more info can I provide so that you can help me?

Sub SAPEXCEL()

If Not IsObject(application) Then

   Set SapGuiAuto  = GetObject("SAPGUI")

   Set application = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(connection) Then

   Set connection = application.Children(0)

End If

If Not IsObject(session) Then

   Set session    = connection.Children(0)

End If

If IsObject(WScript) Then

   WScript.ConnectObject session,     "on"

   WScript.ConnectObject application, "on"

End If

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").text = "KVBI"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/ctxtI_SALOR-LOW").text = "559737"

session.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").setFocus

session.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").caretPosition = 9

session.findById("wnd[0]").sendVKey 4

session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = "20120101"

session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").firstVisibleDate = "20111226"

session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").selectionInterval = "20120101,20120101"

session.findById("wnd[0]/usr/ctxtP_DISVAR").setFocus

session.findById("wnd[0]/usr/ctxtP_DISVAR").caretPosition = 6

session.findById("wnd[0]").sendVKey 4

session.findById("wnd[1]/usr").verticalScrollbar.position = 22

session.findById("wnd[1]/usr").verticalScrollbar.position = 52

session.findById("wnd[1]/usr").verticalScrollbar.position = 97

session.findById("wnd[1]/usr").verticalScrollbar.position = 96

session.findById("wnd[1]/usr").verticalScrollbar.position = 95

session.findById("wnd[1]/usr").verticalScrollbar.position = 94

session.findById("wnd[1]/usr").verticalScrollbar.position = 93

session.findById("wnd[1]/usr").verticalScrollbar.position = 92

session.findById("wnd[1]/usr").verticalScrollbar.position = 91

session.findById("wnd[1]/usr").verticalScrollbar.position = 90

session.findById("wnd[1]/usr").verticalScrollbar.position = 89

session.findById("wnd[1]/usr/lbl[1,6]").setFocus

session.findById("wnd[1]/usr/lbl[1,6]").caretPosition = 4

session.findById("wnd[1]").sendVKey 2

session.findById("wnd[0]/tbar[1]/btn[8]").press

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectedRows = "0"

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").contextMenu

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectContextMenuItem "&XXL"

session.findById("wnd[1]/usr/radRB_OTHERS").setFocus

session.findById("wnd[1]/usr/radRB_OTHERS").select

session.findById("wnd[1]/usr/radRB_1").setFocus

session.findById("wnd[1]/usr/radRB_1").select

session.findById("wnd[1]/tbar[0]/btn[0]").press

End Sub

Former Member
Not what you were looking for? View more on this topic or Ask a question