I am using vba to interact with SAP and get data out, etc...
Generally it all works fine.
In this particular section, when I run the whole program it always errors out - it seems to not be allowing the Excel Sheet to actually open before moving on.
I have tried adding DoEvents and a wait as you can see - but get the same result.
When I run this section independent of the whole program or if I step through here it works fine.
Any ideas?
What is supposed to happen, and what works in all other segments I have coded this way...on the last session.findById("wnd[1]").sendVKey 0 it should open the data from SAP in Excel, then save it. But like I said in this section for some reason the Excel doc isnt opening.
Generally it all works fine.
In this particular section, when I run the whole program it always errors out - it seems to not be allowing the Excel Sheet to actually open before moving on.
I have tried adding DoEvents and a wait as you can see - but get the same result.
When I run this section independent of the whole program or if I step through here it works fine.
Any ideas?
What is supposed to happen, and what works in all other segments I have coded this way...on the last session.findById("wnd[1]").sendVKey 0 it should open the data from SAP in Excel, then save it. But like I said in this section for some reason the Excel doc isnt opening.
Code:
'Export the file
session.findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").pressToolbarButton "&NAVIGATION_PROFILE_TOOLBAR_EXPAND"
session.findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").pressToolbarContextButton "&MB_EXPORT"
session.findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").selectContextMenuItem "&XXL"
'Select Radio button "Select from All Available Formats"
session.findById("wnd[1]/usr/radRB_OTHERS").Select
'Select "Excel (In Existing XXL Format)"
session.findById("wnd[1]/usr/cmbG_LISTBOX").Key = "08"
session.findById("wnd[1]").sendVKey 0
'Acknowledge "Filter criteria..." dialogue box
On Error Resume Next
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").Select
If Err.Number <> 0 Then
session.findById("wnd[1]").sendVKey 0
End If
On Error GoTo 0
'Select "Table" radio button
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").Select
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
DoEvents
Application.Wait Now + #12:00:05 AM#
'Save CS12
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs "C:\temp\COOIS.xlsx"
objExcel.DisplayAlerts = True