Skip to Content

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

SAP macro run in the excel


I run this SAP macro in the excel,

But it's error.

How can I resolve the issue.

Please help.

Sub CAT2()

Dim sapguiauto As Object
Dim application1 As Object
Dim connection As Object
Dim session As Object
Dim wscript As Object

If Not IsObject(Application) Then
   Set sapguiauto = GetObject("SAPGUI")
   Set application1 = 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]/usr/sub/2/tblSAPLCATSTC_CATSD/ctxt[1,1]").Text = "830515127"
session.findById("wnd[0]/usr/sub/2/tblSAPLCATSTC_CATSD/txt[6,1]").Text = "8"
session.findById("wnd[0]/usr/sub/2/tblSAPLCATSTC_CATSD/txt[7,1]").Text = "8"
session.findById("wnd[0]/usr/sub/2/tblSAPLCATSTC_CATSD/txt[8,1]").Text = "8"
session.findById("wnd[0]/usr/sub/2/tblSAPLCATSTC_CATSD/txt[9,1]").Text = "8"
session.findById("wnd[0]/usr/sub/2/tblSAPLCATSTC_CATSD/txt[10,1]").Text = "8"
session.findById("wnd[0]/usr/sub/2/tblSAPLCATSTC_CATSD/txt[10,1]").caretPosition = 20
session.findById("wnd[0]").sendVKey 0
End Sub

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