on 04-16-2015 10:15 PM
do i need to input my login info, since I have auto log in? What changes do I need to do? What more info can I provide so that you can help me?
Sub SAPEXCEL()
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = 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]/tbar[0]/okcd").text = "KVBI"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtI_SALOR-LOW").text = "559737"
session.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").setFocus
session.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").caretPosition = 9
session.findById("wnd[0]").sendVKey 4
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = "20120101"
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").firstVisibleDate = "20111226"
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").selectionInterval = "20120101,20120101"
session.findById("wnd[0]/usr/ctxtP_DISVAR").setFocus
session.findById("wnd[0]/usr/ctxtP_DISVAR").caretPosition = 6
session.findById("wnd[0]").sendVKey 4
session.findById("wnd[1]/usr").verticalScrollbar.position = 22
session.findById("wnd[1]/usr").verticalScrollbar.position = 52
session.findById("wnd[1]/usr").verticalScrollbar.position = 97
session.findById("wnd[1]/usr").verticalScrollbar.position = 96
session.findById("wnd[1]/usr").verticalScrollbar.position = 95
session.findById("wnd[1]/usr").verticalScrollbar.position = 94
session.findById("wnd[1]/usr").verticalScrollbar.position = 93
session.findById("wnd[1]/usr").verticalScrollbar.position = 92
session.findById("wnd[1]/usr").verticalScrollbar.position = 91
session.findById("wnd[1]/usr").verticalScrollbar.position = 90
session.findById("wnd[1]/usr").verticalScrollbar.position = 89
session.findById("wnd[1]/usr/lbl[1,6]").setFocus
session.findById("wnd[1]/usr/lbl[1,6]").caretPosition = 4
session.findById("wnd[1]").sendVKey 2
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectedRows = "0"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").contextMenu
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectContextMenuItem "&XXL"
session.findById("wnd[1]/usr/radRB_OTHERS").setFocus
session.findById("wnd[1]/usr/radRB_OTHERS").select
session.findById("wnd[1]/usr/radRB_1").setFocus
session.findById("wnd[1]/usr/radRB_1").select
session.findById("wnd[1]/tbar[0]/btn[0]").press
End Sub
Hi,
first of all,
if you are Logged into SAP allready, you dont have to put your Logon Data anywhere ...
Are you getting any Errormessages?
If you're working in Excel you should correct the following lines:
If Not IsObject(SapApplication) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SapApplication = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(SAPconnection) Then
Set SAPconnection = SAPapplication.Children(0)
End If
If Not IsObject(SAPsession) Then
Set SAPsession = SAPconnection.Children(0)
End If
Then it should work fine...
greetings
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas!
Thanks! the start of the code works fine, however in VBA I get an error
"Run-time error '91':
Object variable or with block variable not set
Here is the revised code
Sub TEST()
Dim SAPguiAPP As Object
Dim SAPConnection As Object
Dim SAPSession As Object
If Not IsObject(SAPguiAPP) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SAPguiAPP = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(SAPConnection) Then
Set Connection = SAPguiAPP.Children(0)
End If
If Not IsObject(SAPSession) Then
Set SAPSession = SAPConnection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject SAPSession, "on"
WScript.ConnectObject SAPguiAPP, "on"
End If
SAPSession.findById("wnd[0]").maximize --------------------THIS IS WHERE I GET ERROR 91
SAPSession.findById("wnd[0]/tbar[0]/okcd").Text = "KVBI"
SAPSession.findById("wnd[0]").sendVKey 0
SAPSession.findById("wnd[0]/usr/ctxtI_SALOR-LOW").Text = "559737"
SAPSession.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").SetFocus
SAPSession.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").caretPosition = 9
SAPSession.findById("wnd[0]").sendVKey 4
SAPSession.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = "20120101"
SAPSession.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").firstVisibleDate = "20111226"
SAPSession.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").selectionInterval = "20120101,20120101"
SAPSession.findById("wnd[0]/usr/ctxtP_DISVAR").SetFocus
SAPSession.findById("wnd[0]/usr/ctxtP_DISVAR").caretPosition = 6
SAPSession.findById("wnd[0]").sendVKey 4
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 22
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 52
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 97
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 96
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 95
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 94
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 93
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 92
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 91
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 90
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 89
SAPSession.findById("wnd[1]/usr/lbl[1,6]").SetFocus
SAPSession.findById("wnd[1]/usr/lbl[1,6]").caretPosition = 4
SAPSession.findById("wnd[1]").sendVKey 2
SAPSession.findById("wnd[0]/tbar[1]/btn[8]").press
SAPSession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectedRows = "0"
SAPSession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").contextMenu
SAPSession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectContextMenuItem "&XXL"
SAPSession.findById("wnd[1]/usr/radRB_OTHERS").SetFocus
SAPSession.findById("wnd[1]/usr/radRB_OTHERS").Select
SAPSession.findById("wnd[1]/usr/radRB_1").SetFocus
SAPSession.findById("wnd[1]/usr/radRB_1").Select
SAPSession.findById("wnd[1]/tbar[0]/btn[0]").press
End Sub
Hello Thomas,
First let me thank you for all your help!
I tried running the macro in excel, both with and without logon in SAP!
I am fairly new to macro and scripting! Where can I check if "barberpole" running?
I have been trying to run another macro --- and I get the same error!
Sub Test()
Dim SAPguiAPP As Object
Dim Connection As Object
Dim Session As Object
If Not IsObject(SAPguiAPP) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SAPguiAPP = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = SAPguiAPP.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 SAPguiAPP, "on"
End If
Session.FindById("wnd[0]").resizeWorkingPane 267, 40, False
Session.FindById("wnd[0]/usr/txtRSYST-MANDT").Text = "100" THIS IS WHERE I GET ERROR 91
Session.FindById("wnd[0]/usr/txtRSYST-BNAME").Text = "XXXX"
Session.FindById("wnd[0]/usr/pwdRSYST-BCODE").Text = "********"
Session.FindById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus
Session.FindById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 8
Session.FindById("wnd[0]").sendVKey 0
Session.FindById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "F00012"
Session.FindById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00012"
Session.FindById("wnd[0]/usr/ctxtCN_PROJN-LOW").Text = "101884A"
Session.FindById("wnd[0]/usr/ctxtCN_PROJN-LOW").caretPosition = 7
Session.FindById("wnd[0]/tbar[1]/btn[8]").press
Session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").contextMenu
Session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectContextMenuItem "&XXL"
Session.FindById("wnd[1]/tbar[0]/btn[0]").press
End Sub
Shiv-
The line you're referencing (SAPSession.findById("wnd[0]").maximize) where the script is failing is not important to the script functionality. It's for window sizing. You can remove it without detriment to the rest.
I'd also ask if you're logged into SAP when attempting the script run. The script you've written requires you to be logged in.
Hello.
This will work:
Sub TEST()
Dim SAPguiAPP
Dim SAPConnection
Dim SAPSession
Dim SAPGuiAuto
If Not IsObject(SAPguiAPP) Then
Set SAPGuiAuto = GetObject("SAPGUI")
Set SAPguiAPP = SAPGuiAuto.GetScriptingEngine
End If
If Not IsObject(SAPConnection) Then
Set SAPConnection = SAPguiAPP.Children(0)
End If
If Not IsObject(SAPSession) Then
Set SAPSession = SAPConnection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject SAPSession, "on"
WScript.ConnectObject SAPguiAPP, "on"
End If
SAPSession.findById("wnd[0]").maximize '--------------------THIS IS WHERE I GET ERROR 91
SAPSession.findById("wnd[0]/tbar[0]/okcd").Text = "KVBI"
SAPSession.findById("wnd[0]").sendVKey 0
SAPSession.findById("wnd[0]/usr/ctxtI_SALOR-LOW").Text = "559737"
SAPSession.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").SetFocus
SAPSession.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").caretPosition = 9
SAPSession.findById("wnd[0]").sendVKey 4
SAPSession.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = "20120101"
SAPSession.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").firstVisibleDate = "20111226"
SAPSession.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").selectionInterval = "20120101,20120101"
SAPSession.findById("wnd[0]/usr/ctxtP_DISVAR").SetFocus
SAPSession.findById("wnd[0]/usr/ctxtP_DISVAR").caretPosition = 6
SAPSession.findById("wnd[0]").sendVKey 4
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 22
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 52
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 97
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 96
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 95
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 94
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 93
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 92
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 91
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 90
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 89
SAPSession.findById("wnd[1]/usr/lbl[1,6]").SetFocus
SAPSession.findById("wnd[1]/usr/lbl[1,6]").caretPosition = 4
SAPSession.findById("wnd[1]").sendVKey 2
SAPSession.findById("wnd[0]/tbar[1]/btn[8]").press
SAPSession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectedRows = "0"
SAPSession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").contextMenu
SAPSession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectContextMenuItem "&XXL"
SAPSession.findById("wnd[1]/usr/radRB_OTHERS").SetFocus
SAPSession.findById("wnd[1]/usr/radRB_OTHERS").Select
SAPSession.findById("wnd[1]/usr/radRB_1").SetFocus
SAPSession.findById("wnd[1]/usr/radRB_1").Select
SAPSession.findById("wnd[1]/tbar[0]/btn[0]").press
End Sub
Shiv-
I dumped your script into my own system and revised to run. The below ran successfully on my computer:
Function Test()
Dim Application
If Not IsObject(Application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Application = 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]/tbar[0]/okcd").Text = "KVBI"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtI_SALOR-LOW").Text = "559737"
session.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").SetFocus
session.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").caretPosition = 9
session.findById("wnd[0]").sendVKey 4
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = "20120101"
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").firstVisibleDate = "20111226"
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").selectionInterval = "20120101,20120101"
session.findById("wnd[0]/usr/ctxtP_DISVAR").SetFocus
session.findById("wnd[0]/usr/ctxtP_DISVAR").caretPosition = 6
session.findById("wnd[0]").sendVKey 4
session.findById("wnd[1]/usr").verticalScrollbar.Position = 22
session.findById("wnd[1]/usr").verticalScrollbar.Position = 52
session.findById("wnd[1]/usr").verticalScrollbar.Position = 97
session.findById("wnd[1]/usr").verticalScrollbar.Position = 96
session.findById("wnd[1]/usr").verticalScrollbar.Position = 95
session.findById("wnd[1]/usr").verticalScrollbar.Position = 94
session.findById("wnd[1]/usr").verticalScrollbar.Position = 93
session.findById("wnd[1]/usr").verticalScrollbar.Position = 92
session.findById("wnd[1]/usr").verticalScrollbar.Position = 91
session.findById("wnd[1]/usr").verticalScrollbar.Position = 90
session.findById("wnd[1]/usr").verticalScrollbar.Position = 89
session.findById("wnd[1]/usr/lbl[1,6]").SetFocus
session.findById("wnd[1]/usr/lbl[1,6]").caretPosition = 4
session.findById("wnd[1]").sendVKey 2
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectedRows = "0"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").contextMenu
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectContextMenuItem "&XXL"
session.findById("wnd[1]/usr/radRB_OTHERS").SetFocus
session.findById("wnd[1]/usr/radRB_OTHERS").Select
session.findById("wnd[1]/usr/radRB_1").SetFocus
session.findById("wnd[1]/usr/radRB_1").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press
End Function
Hi guys,
I think the error is already a few lines before:
Sub TEST()
Dim SAPguiAPP As Object
Dim SAPConnection As Object
Dim SAPSession As Object
If Not IsObject(SAPguiAPP) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SAPguiAPP = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(SAPConnection) Then
'Set Connection = SAPguiAPP.Children(0)
Set SAPConnection = SAPguiAPP.Children(0)
End If
If Not IsObject(SAPSession) Then
Set SAPSession = SAPConnection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject SAPSession, "on"
WScript.ConnectObject SAPguiAPP, "on"
End If
SAPSession.findById("wnd[0]").maximize --------------------THIS IS WHERE I GET ERROR 91
. . .
Regards,
ScriptMan
Hi Shiv,
First of all "open" the Arrow at the right bottom (< )
there normaly shows up a "Barber Pole" (in white and red) this indicates if the Script could Connect or not.
Then I have another suggestion to make;
Insert a Module into vba and put your Code in there -
then test it again ...
Anyway ...
do you know what debugging means?
Start the Code with F8 and step through everey line of code and watch where it fails (etc)
Also you can see which Objects and Variables are Initiated (and all) if you hover the Mouse over them (like SapApplication, SapGuiAuto etc)
Greetings from Germany
PS:
By the Way - you dont have to Declare the "Objects" if you use them only in One Sub (Except there
Hello!
Oh ok, so I checked and the scrip is not running! I guess I will first have to enable scripting in SAP.
I did the test again after inserting the module and got the same result...error 91
I know about debugging, did do it for both the codes and got Error 91 for line marked in yellow!
Got it about declaring objects.
Thank you!!!
Hi Shiv,
as already Holger said:
wrong:
Dim SAPguiAPP as Object
Dim SAPConnection as Object
Dim SAPSession as Object
Dim SAPGuiAuto as Object
right:
Dim SAPguiAPP
Dim SAPConnection
Dim SAPSession
Dim SAPGuiAuto
Sometimes the start of a transaction's better this way:
SAPSession.findById("wnd[0]/tbar[0]/okcd").Text = "/nKVBI"
Regards,
ScriptMan
Hi ScriptMan,
Thank you so much ScriptMan and Holger! You my Frnds are life savers!
Just a quick question, hopefully then I will stop disturbing you after this! So the macro works fine but in between I have to do some clicks on what kind of spreadsheet I want and that if I want to save and replace the file called "export".
Is there a line I can insert in the macro so I don't have do any clicks and it automatically replaces the file?
Thanks!
Hi Thomas!
I looked at the link, however I did not understand much, Here is my code-
Sub FinalTest()
Dim SAPguiAPP
Dim SAPConnection
Dim SAPsession
Dim SAPGuiAuto
If Not IsObject(SAPguiAPP) Then
Set SAPGuiAuto = GetObject("SAPGUI")
Set SAPguiAPP = SAPGuiAuto.GetScriptingEngine
End If
If Not IsObject(SAPConnection) Then
Set SAPConnection = SAPguiAPP.Children(0)
End If
If Not IsObject(SAPsession) Then
Set SAPsession = SAPConnection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject Application, "on"
End If
SAPsession.findById("wnd[0]").maximize
SAPsession.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "F00012"
SAPsession.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00012"
SAPsession.findById("wnd[0]/usr/ctxtCN_PROJN-LOW").Text = "101884A"
SAPsession.findById("wnd[0]/usr/ctxtCN_PROJN-LOW").caretPosition = 7
SAPsession.findById("wnd[0]/tbar[1]/btn[8]").press
SAPsession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").contextMenu
SAPsession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectContextMenuItem "&XXL"
Path = InputBox("Please enter a filename: ", "export", "C:\Users\CASHJAN\Desktop.mhtml")
Set Wshell = CreateObject("WScript.Shell")
Wshell.Run """C:\Users\CASHJAN\Desktop\save_as.vbs ""export" & Path
SAPsession.findById("wnd[1]/tbar[0]/btn[0]").press
If WScript.arguments.Count > 0 Then
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileExists(WScript.arguments(0)) Then
Set myfile = fs.GetFile(WScript.arguments(0))
myfile.Delete
End If
Set Wshell = CreateObject("WScript.Shell")
Do
bWindowFound = Wshell.AppActivate("Save As")
WScript.Sleep 1000
Loop Until bWindowFound
Do
Wshell.AppActivate "Save As"
Wshell.SendKeys "%n"
WScript.Sleep 400
Wshell.AppActivate "Save As"
Wshell.SendKeys WScript.arguments(0)
WScript.Sleep 400
Wshell.AppActivate "Save As"
Wshell.SendKeys "%s"
WScript.Sleep 400
bWindowFound = Wshell.AppActivate("Save As")
WScript.Sleep 400
Loop Until Not bWindowFound
End If
End Sub
What do I need to change? Have I inserted the file name correctly and is the position of "save file" macro correct? Coz I get error of file not found in system
I got access and checked, I don't have the box available!
I have been trying this code
Sub TEST()
Dim SAPguiAPP
Dim SAPConnection
Dim SAPSession
If Not IsObject(SAPguiAPP) Then
Set SAPGuiAuto = GetObject("SAPGUI")
Set SAPguiAPP = SAPGuiAuto.GetScriptingEngine
End If
If Not IsObject(SAPConnection) Then
Set SAPConnection = SAPguiAPP.Children(0)
End If
If Not IsObject(SAPSession) Then
Set SAPSession = SAPConnection.Children(0)
End If
If IsObject(wscript) Then
wscript.ConnectObject SAPSession, "on"
wscript.ConnectObject SAPguiAPP, "on"
End If
SAPSession.findById("wnd[0]").maximize
SAPSession.findById("wnd[0]/tbar[0]/okcd").Text = "/nKVBI"
SAPSession.findById("wnd[0]").sendVKey 0
SAPSession.findById("wnd[0]/usr/ctxtI_SALOR-LOW").Text = "559737"
SAPSession.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").SetFocus
SAPSession.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").caretPosition = 9
SAPSession.findById("wnd[0]").sendVKey 4
SAPSession.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = "20120101"
SAPSession.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").firstVisibleDate = "20111226"
SAPSession.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").selectionInterval = "20120101,20120101"
SAPSession.findById("wnd[0]/usr/ctxtP_DISVAR").SetFocus
SAPSession.findById("wnd[0]/usr/ctxtP_DISVAR").caretPosition = 6
SAPSession.findById("wnd[0]").sendVKey 4
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 22
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 52
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 97
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 96
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 95
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 94
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 93
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 92
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 91
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 90
SAPSession.findById("wnd[1]/usr").verticalScrollbar.Position = 89
SAPSession.findById("wnd[1]/usr/lbl[1,6]").SetFocus
SAPSession.findById("wnd[1]/usr/lbl[1,6]").caretPosition = 4
SAPSession.findById("wnd[1]").sendVKey 2
SAPSession.findById("wnd[0]/tbar[1]/btn[8]").press
SAPSession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectedRows = "0"
SAPSession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").contextMenu
SAPSession.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectContextMenuItem "&XXL"
SAPSession.findById("wnd[1]/usr/radRB_OTHERS").SetFocus
SAPSession.findById("wnd[1]/usr/radRB_OTHERS").Select
SAPSession.findById("wnd[1]/usr/radRB_1").SetFocus
SAPSession.findById("wnd[1]/usr/radRB_1").Select
SAPSession.findById("wnd[1]/tbar[0]/btn[0]").press
Path = "C:\Users\CASHJAN\Desktop\export.MHTML"
Set Wshell = CreateObject("WScript.Shell")
Wshell.Run """C:\Users\CASHJAN\Documents\New folder\final kvbi\save_as.vbs """ & Path-------GET STUCK HERE SAYS FILE NOT FOUND, however file is here
SAPSession.findById("wnd[1]/tbar[0]/btn[0]").press
Save_as.vbs includes:
If wscript.arguments.Count > 0 Then
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileExists(wscript.arguments(0)) Then
Set myfile = fs.GetFile(wscript.arguments(0))
myfile.Delete
End If
Set Wshell = CreateObject("WScript.Shell")
Do
bWindowFound = Wshell.AppActivate("Save As")
wscript.Sleep 1000
Loop Until bWindowFound
Do
Wshell.AppActivate "Save As"
Wshell.SendKeys "%n"
wscript.Sleep 400
Wshell.AppActivate "Save As"
Wshell.SendKeys wscript.arguments(0)
wscript.Sleep 400
Wshell.AppActivate "Save As"
Wshell.SendKeys "%s"
wscript.Sleep 400
bWindowFound = Wshell.AppActivate("Save As")
wscript.Sleep 400
Loop Until Not bWindowFound
End If
End Sub
Hi! I got access and that box is missing,
I tried this however---
When I enter
Path = "C:\Users\CASHJAN\Desktop\export.MHTML"
Set Wshell = CreateObject("WScript.Shell")
Wshell.Run """C:\Users\CASHJAN\Documents\New folder\final kvbi\save_as.vbs """ & Path-------GET STUCK HERE SAYS FILE NOT FOUND, however file is here
The save file does not recognize it. I have to manually click save and replace.
Thanks!
Hi Shiv,
I am fairly new to macro and scripting! Where can I check if "barberpole" running?
In the Statusbar on the Right is an Arrow you can click- a Pane opens and you can see things like if youre Writing in "INS" or "OVR" and statusses about SAP-
On the right outside is the "BarberPole" if this thing is disabled (not "scrolling") youre not Connected via Script
Check ScriptMans reply pls
You must!!! watch for correct Syntax
Second thing about coding:
You can spare much typing if you use a "shortcut" "With" and End With
for Example:
With SapSession
.findbyid("wnd[0]").sendvkey(0)
End With
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.