Hello, I am trying to run an report daily and save to a specific location. Here is the code, how do I command to say "every time I run the script to look at yesterday's date"
Code:
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 = "mcrq"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/ctxtSL_0001-LOW").text = "0110"
session.findById("wnd[0]/usr/ctxtSL_SPTAG-LOW").text = "6/05/2019"
session.findById("wnd[0]/usr/ctxtSL_SPTAG-LOW").setFocus
session.findById("wnd[0]/usr/ctxtSL_SPTAG-LOW").caretPosition = 9
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/lbl[20,3]").setFocus
session.findById("wnd[0]/usr/lbl[20,3]").caretPosition = 9
session.findById("wnd[0]/tbar[1]/btn[7]").press
session.findById("wnd[1]/usr/sub:SAPLMCS2:0201/radLMCS2-MRKKZ[1,0]").select
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/mbar/menu[0]/menu[6]/menu[1]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "R:\Production Schedules\Macro"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "mcrq.xls"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 8
session.findById("wnd[1]/tbar[0]/btn[11]").press
session.findById("wnd[0]/tbar[0]/btn[12]").press
session.findById("wnd[0]/tbar[0]/btn[12]").press