I have recorded one SAP scripting and am using the script in my VBA code to run. My issue is one dialog box coming on clicking on the report generate window is not getting captured through SAP script recording .Rest all steps are getting recorded through SAP and I have used these script in VBA. as shown below :
Sub sap_scripting()
Set SAPGuiAuto = GetObject("SAPGUI")
Set ObjGui = SAPGuiAuto.GetScriptingEngine
Set ObjConn = ObjGui.Children(0)
Set session = ObjConn.Children(0)
'below SAP script recorded steps
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "Tcode"
--------------------------------
--------------------------------
session.findById("wnd[1]/tbar[0]/btn[0]").press '*This opens new dialog window for file explorer
'from here I lost the control on VBA code
' I am trying to capture window through may manual vba code but this is not getting
executed as the dialogue box window is waiting for some action.
Set WshShell = CreateObject("WScript.Shell")
ret = WshShell.AppActivate("Save As")
Loop Until ret = True
ret = WshShell.AppActivate("Save As")
If ret = True Then
ret = WshShell.AppActivate("Save As")
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "newfilename"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
End If
I am trying to select the folder from Save As file dialogue box and give the file name through VBA. Please help me how to fix issue.First issue is VBA is losing control when Dialogue box appears.Second how to select the folder and give file name