I need to get the user ID into VBA code.
Like on the picture:
I tried
UserId = Session.FindById("wnd[0]").User
But it failed. What's the right way?
I need to get the user ID into VBA code.
Like on the picture:
I tried
UserId = Session.FindById("wnd[0]").User
But it failed. What's the right way?
This proved to be easy:
Sub Getuser()
Dim SapGuiAuto
Dim SetApp
Dim Connection
Dim Session
Set SapGuiAuto = GetObject("SAPGUI")
Set SetApp = SapGuiAuto.GetScriptingEngine
Set Connection = SetApp.Children(0)
Set Session = Connection.Children(0)
Session.FindById("wnd[0]").Maximize
Session.FindById("wnd[0]/mbar/menu[4]/menu[11]").Select
MsgBox Session.FindById("wnd[1]/usr/txtSYST-UNAME").Text
Session.FindById("wnd[1]/tbar[0]/btn[0]").Press
End Sub