Skip to Content
0
Former Member
Jun 23, 2015 at 10:39 AM

SAP macro run in the excel

31 Views

Hi,

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]").maximize
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]").SetFocus
session.findById("wnd[0]/usr/sub/2/tblSAPLCATSTC_CATSD/txt[10,1]").caretPosition = 20
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[11]").press
End Sub