on 02-24-2015 1:43 PM
Hi,
I am trying to run a a script via Excel that will log on to SAP and run a report for me. However on occasion I will get the following error:
My code is as follows:
Dim SapGuiApp As Object
Dim oConnection As Object
Dim session As Object
Dim SAPCon As Object, SAPSesi As Object
Dim SAPGUIAuto As Object, SAPApp As Object
Dim sMsg As String
Dim result As String
Set SAPSesi = Nothing
Set SapGuiApp = Nothing
Set oConnection = Nothing
If SapGuiApp Is Nothing Then
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
SendKeys "{ENTER}"
If oConnection Is Nothing Then
Set oConnection = SapGuiApp.OpenConnection(SAPSystemBox.Value, True)
End If
If SAPSesi Is Nothing Then
Set SAPSesi = oConnection.Children(0)
End If
Application.DisplayAlerts = False
With SAPSesi
.findbyid("wnd[0]/usr/txtRSYST-MANDT").Text = CStr(ClientBox.Value)
The error occurs on the last line that I quoted (.findbyid("wnd[0]/usr/txtRSYST-MANDT").Text = CStr(ClientBox.Value))
Any ideas on how to get past this?
Hello. It could be that this field you refer to is not usable in same way as it is in SAPGUI application.
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
SAP GUI modal called by this Scripting object is bit different to SAP GUI Dialog.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use one of the open sessions called from SAP GUI. You can check it in document area of this Forum. I have publish a guidance how to Setup an interactive EXCEL MACRO-ENABLED WORKBOOK. This Loop over all existing sessions. In a customized userform you can select one this this list for execution of script.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.