Skip to Content
0
Former Member
Nov 06, 2015 at 03:25 PM

Convert vbs2vba (Run SAP GUI Script as Macro in Excel)

843 Views

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!