Skip to Content
Former Member
Oct 10, 2012 at 12:29 PM

Extract data from SAP to Excell


Hi SAP community,

i have next question.

does anybody know, hov can i extract data from SAP direct to Excell. ineed extract line by line

i have example next code

Sub testExtData()

If Not IsObject(sap) Then

Set SapGuiAuto = GetObject("SAPGUI")

Set sap = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(Connection) Then

Set Connection = sap.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 sap, "on"

End If


session.findById("wnd[0]/tbar[0]/okcd").Text = "/nmb52"

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

session.findById("wnd[0]/usr/ctxtWERKS-LOW").Text = "a709"

session.findById("wnd[0]/usr/ctxtLGORT-LOW").Text = "ua38"


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

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

'x - rows numb

Cells(x, 1) = session.findById("wnd[0]/usr/sub/1[0,0]/sub/1/2[0,0]/sub/1/2/x[0,x]/lbl[1,x]").Text

Cells(x, 2) = session.findById("wnd[0]/usr/sub/1[0,0]/sub/1/2[0,0]/sub/1/2/x[0,x]/lbl[14,x]").Text


End Sub

Thank for response