SAPGUI vbscript if statement

mathiasdobel

New Member
Joined
Feb 16, 2018
Messages
1
Hi Mr. Excel,

I am new to SAP scripting and I am facing an issue in my script.

When I run it, I sometimes get the question seen in the picture, but not always (As you can see I am just above the limit of 5000 and sometimes below it.).

My question is then if it is possible to run the script where, if I get this message, it will run all, but if I don't get this message it will still run the script.



My current code is:
Code:
   Set SapGuiAuto = GetObject("SAPGUI")
   Set SAPApp = SapGuiAuto.GetScriptingEngine
   Set SAPCon = SAPApp.Children(0)

   Set session = SAPCon.Children(0)
If IsObject(WScript) Then
   WScript.ConnectObject session, "on"
   WScript.ConnectObject Application, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nCM01"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/txt[35,3]").Text = ""
session.findById("wnd[0]/usr/txt[35,5]").Text = "513"
session.findById("wnd[0]/usr/txt[35,7]").Text = "bj18"
session.findById("wnd[0]/usr/txt[35,7]").SetFocus
session.findById("wnd[0]/usr/txt[35,7]").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/mbar/menu[3]/menu[0]").Select
session.findById("wnd[1]/usr/chkRC65A-HIEVER").Selected = True
session.findById("wnd[1]/usr/chkRC65A-ANVER").Selected = True
session.findById("wnd[1]/usr/ctxtRC65A-HNAME").Text = "støbemas"
session.findById("wnd[1]/usr/ctxtRC65A-HWERKS").Text = "bj18"
session.findById("wnd[1]/usr/txtRC65A-ZABIS").Text = "      180"
session.findById("wnd[1]/usr/txtRC65A-ZABIS").SetFocus
session.findById("wnd[1]/usr/txtRC65A-ZABIS").caretPosition = 9
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/mbar/menu[4]/menu[3]/menu[1]/menu[0]").Select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press

Thank you in advance
 
Last edited by a moderator:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,054
Messages
6,122,901
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top