If however you want to use early binding so that your VBA editor might show the properties and methods of the objects you are using, you need to add a reference to sapfewse.ocx in the SAP GUI installation folder. It uses late binding, the line Set SapGuiAuto = GetObject("SAPGUI") defines the SapGuiAuto object. The provided script should work if copied directly into a VBA macro. The output format is a bit messy, it records things like selecting text, clicking inside a text field, etc. Within that the More button allows you to see/change the file that the VB Script is recorded to. Then find the Script Recording and Playback menu item. To help find the names of elements such as wnd/tbar/btn you can use script recording.Ĭlick the customize local layout button, it probably looks a bit like this: Session.findById("wnd/usr/ctxtDY_PATH").text = "C:\Temp\" Session.findById("wnd/usr/ctxtDY_FILENAME").text = "test.txt" Session.findById("wnd/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG").select Therefore SAP has decided to set the so-called killbit for the SAP GUI Scripting ActiveX object (see SAP Note 1261706 for more information). Even though SAP applies strict security policies ActiveX objects may be vulnerable to attacks. Session.findById("wnd/usr/txtMAX_SEL").text = "2" SAP GUI Scripting makes use of an ActiveX object called sapfewse.ocx. Session.findById("wnd/usr/ctxtDATABROWSE-TABLENAME").Text = "T001" Set session = SAPCon.Children(0) 'Get the first session (window) on that connection Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI Set SapGuiAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object Here is a simple example based on a SAP system I have access to. It records macros in VBScript which is nearly identical to Excel VBA and can usually be copied and pasted into an Excel macro directly. The SAP GUI has a macro recording tool much like Excel does. In fact you can call the SAP GUI directly from an Excel macro. SAP GUI scripting allows you to automate the Windows SAP GUI in much the same way as you automate Excel. In that case you probably want to use SAP GUI Scripting. However as a general rule people looking for this sort of answer are looking for an immediate solution that does not require their IT department to spend months customizing their SAP system. An ABAP program that exports the data and/or an RFC that your macro can call to directly get the data or have SAP create the file is probably best. Upload Excel to an SAP grid control : Solution We call up a JavaScript function that reads the Excel file via Excel automation and then inserts the values into the grid cells via SAP GUI Scripting. This all depends on what sort of access you have to your SAP system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |