Skip to Content
0
Former Member
May 26, 2005 at 07:14 PM

sapgui scripting - export report to Excel then return to sap

1317 Views

I am new to SAP and my company has just updated to 4.7. I can export a report to MS Excel as spreadsheet, run a excel macro on the spreadsheet in excel, save the excel workbook in a local directory, then close & exit excel. However, I can not get the script to continue after excel is closed. The script does not respond. the following is an example of the 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]/usr/ctxtS_POSID-LOW").text = "me24810110"

session.findById("wnd[0]/usr/ctxtS_POSID-HIGH").text = "me24810111"

session.findById("wnd[0]/tbar[1]/btn[8]").press

session.findById("wnd[0]/tbar[1]/btn[43]").press

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[1]/usr/sub:SAPLSPO5:0101/radSPOPLI-SELFLAG[0,0]").select

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[1]/tbar[0]/btn[0]").press

set ns1=createobject("WScript.shell")

ns1.AppActivate "Microsoft Excel"

ns1.SendKeys "%TMM", True

ns1.SendKeys "PERSONAL.XLS!EOM_Status", True

ns1.SendKeys "%R", True

ns1.SendKeys "%FA H:\2005_Monthly_Status\EOM_CIP_Status.xls ", True

ns1.SendKeys "%Y", True

ns1.SendKeys "%Fx", True

Now... from here, the SAP report that was exported is showing on the screen, but I can't get the script to recognize any of the controls on the screen.

Any help would be greatly appreciated.