Save SAP file as spreadsheet to desktop using VBA
I've scoured the internet and hit a wall. Below is as far as I've gotten with a macro I'm attempting. I need to enter a SAP transaction, enter a part number and serial number, and save the resulting information as a spreadsheet to my desktop. From there my JAVA code will take that spreadsheet and work it's magic.
I'm having a hard time discovering how to code the saving of the file (can't record that part).
How do I control both the file format and the file path?
Thank you in advance.
Public Sub SimpleSAPExport()
Set SAPGUIAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object
Set SAPApp = SAPGUIAuto.GetScriptingEngine 'Get the currently running SAP GUI
Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected
Set session = SAPCon.Children(0) 'Get the first session (window) on that connection
'Start the transaction to view a table
'enter part specific information
session.findById("wnd/usr/ctxtW_MATERIAL").Text = "3842151-3"
session.findById("wnd/usr/txtW_SERNR").Text = "14-168522-05838"
session.findById("wnd/usr/btnDOWNLOAD").press 'starts the download
'lost here, how do I controll the file format and save location
session.findById("wnd/tbar/btn").press 'exit transaction