Hi All,
I have a macro which run automatically at a specific time which connect SAP and run the SAP script. The input of the starting date is expected to enter the current date deduct by 7 days.
Below is the code which the starting date need to be specified a date. I am not able to use FORMAT(DATE) at starting date. Thank you.
I have a macro which run automatically at a specific time which connect SAP and run the SAP script. The input of the starting date is expected to enter the current date deduct by 7 days.
Below is the code which the starting date need to be specified a date. I am not able to use FORMAT(DATE) at starting date. Thank you.
Code:
Sub aa()
Application.DisplayAlerts = False
Shell "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", vbNormalFocus
Set WSHShell = CreateObject("WScript.Shell")
Do Until WSHShell.AppActivate("SAP Logon")
Application.Wait Now + TimeValue("0:00:01")
Loop
If Not IsObject(SAPguiApp) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SAPguiApp = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = SAPguiApp.Openconnection("CP0 [Back Office]", True)
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
On Error Resume Next
If Session.findById("wnd[1]").Text = "License Information for Multiple Logon" Then
Session.findById("wnd[1]/usr/radMULTI_LOGON_OPT2").Select
Session.findById("wnd[1]/usr/radMULTI_LOGON_OPT2").SetFocus
Session.findById("wnd[1]").sendVKey 0
End If
Session.findById("wnd[0]").maximize
Session.findById("wnd[0]/tbar[0]/okcd").Text = "T-CODE"
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]").sendVKey 4
Session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = "20190215"
Session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").selectionInterval = "20190215,20190215"
Session.findById("wnd[0]/usr/tabsTABSTRIP_TABSTRIP/tabpMQML/ssub%_SUBSCREEN_TABSTRIP:SAPLZQN_MON_BROWSER:0510/ctxtS_QMDAT-HIGH").Text = Format(Date - 1, "dd.mm.yyyy")