简体   繁体   中英

How to get text from SAP to Excel CellValue via VBA Script

I just started with VBA and SAP GUI Scripts.

I am able to enter to the operation in SAP GUI via VBA but I am unable to find how to select or copy the value of these fields.

While recording the script via SAP GUI, copying the fields into the clipboard won't appear in the script as an action.

Any help or reference is highly appreciated.

Please find code and screenshot below.

Sub XXXX()
Call SAPConnections
Session.FindById("wnd[0]/tbar[0]/okcd").Text = "Operation"
Session.FindById("wnd[0]").SendVKey 0
Session.FindById("wnd[0]/usr/ctxtP_MATRL").Text = "PartNumber"
Session.FindById("wnd[0]").SendVKey 8
Session.FindById("wnd[0]/tbar[1]/btn[1]").Press

截屏

The screen you are showing is named an "ABAP List".

It contains labels and text fields, they belong to the property Children of the GuiUserArea object , and their IDs are made of prefix lbl or txt followed by the column and row numbers. The respective SAP GUI Scripting objects are GuiLabel and GuiTextField , for example:

  • label at column 0 (first column) row 12: /app/con[0]/ses[0]/wnd[0]/usr/lbl[0,12]
  • text field at column 22 row 12: /app/con[0]/ses[0]/wnd[0]/usr/txt[22,12]

If you want to know all the fields which are in the ABAP list, you must loop at the property Children of the GuiUserArea object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM