on 11-06-2015 3:25 PM
Hello everybody,
I recorded the following simple script in SAP wich only runs the transaction /nse16. When I run this file in Windows it works.
SE16.vbs:
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]").resizeWorkingPane 128,41,false
session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
session.findById("wnd[0]").sendVKey 0
How can I run this script from Excel as a macro?
Sub SapMacro()
'
' Run Transaction SE16
'
'How to transform the vbs to an Excel Macro?
End Sub
I am allready logged in to the SAP-System an Scripting ist enabled in SAP.
Thanks!
Hello Public User,
try this:
Sub SapMacro()
'
' Run Transaction SE16
'
'How to transform the vbs to an Excel Macro?
Set SapGuiAuto = GetObject("SAPGUI")
If Not IsObject(SapGuiAuto) Then
Exit Sub
End If
Set App = SapGuiAuto.GetScriptingEngine
If Not IsObject(App) Then
Exit Sub
End If
Set Connection = App.Children(0)
If Not IsObject(Connection) Then
Exit Sub
End If
Set session = Connection.Children(0)
If Not IsObject(session) Then
Exit Sub
End If
session.findById("wnd[0]").resizeWorkingPane 128, 41, False
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nse16"
session.findById("wnd[0]").sendVKey 0
End Sub
The variable name Application is not allowed in Office context, it is occupied from Office. The code is nearly the same as VBS, there is no great difference.
Let us know your results.
Cheers
Stefan
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.