我想用 VBA 制作打印屏幕,但不幸的是我只有 VBA 的屏幕。
如何以正确的方式做到这一点?
请在下面找到我的脚本:
Sub mb()
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)
session.findbyId("wnd[0]").maximize
session.findbyId("wnd[0]/tbar[0]/okcd").Text = "/n"
session.findbyId("wnd[0]").sendVKey 0
session.findbyId("wnd[0]/tbar[0]/okcd").Text = "fs10n"
session.findbyId("wnd[0]").sendVKey 0
session.findbyId("wnd[0]/usr/ctxtSO_SAKNR-LOW").Text = Cells(5, 2)
session.findbyId("wnd[0]/usr/ctxtSO_BUKRS-LOW").Text = Cells(5, 3)
session.findbyId("wnd[0]/usr/txtGP_GJAHR").Text = Cells(5, 4)
session.findbyId("wnd[0]/usr/txtGP_GJAHR").SetFocus
session.findbyId("wnd[0]/usr/txtGP_GJAHR").caretPosition = 4
session.findbyId("wnd[0]/tbar[1]/btn[8]").press
'session.findById("wnd[0]/usr/cntlFDBL_BALANCE_CONTAINER/shellcont/shell").pressToolbarContextButton "&MB_EXPORT"
'session.findById("wnd[0]/usr/cntlFDBL_BALANCE_CONTAINER/shellcont/shell").selectContextMenuItem "&HTML"
session.findbyId("wnd[0]/usr/cntlFDBL_BALANCE_CONTAINER/shellcont/shell").setCurrentCell Cells(5, 5), "BALANCE_CUM"
AppActivate
Application.SendKeys "(%{1068})"
DoEvents
Cells(1, 1).Select
ActiveSheet.Paste