on 06-23-2015 11:39 AM
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
When your code does not find correct fields caused by not calling CAT2 by script it will fail.
Your explaination what happen as error is too poor to give an better answer. May you can send an screenshot of error or more Information?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.