在 VBA 中使用 SAP GUI 脚本时,如何在编码时查看 SAP GUI 对象属性 - 就像在 IntelliSense 中一样?

When using SAP GUI Scripting in VBA, how can I view SAP GUI objects properties while coding - like in IntelliSense?

有没有办法查看 SAP GUI 对象的属性?

像这样:

但是对于像下面这样的 SAP 对象:

Set SAPGuiAuto = GetObject("SAPGUI")
Set App = SAPGuiAuto.GetScriptingEngine
Set Connection = App.Children(0)
Set SAPSession = Connection.Children(0)

我在阅读了这个 post 的答案的最后一部分后提出这个问题:VBA general way for pulling data out of SAP

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.

SAP 团队宣传得如此糟糕,他们绝对应该在这方面做得更好。

基本上您首先需要添加对 SAP 对象模型的引用,VBA 将理解这些库。不知道您对对象模型的引用有多熟悉。基本上,在您的 VBA 编辑器上,点击工具,然后点击参考,然后点击浏览,找到这个文件:"C:\Program Files\SAP\FrontEnd\SAPgui\sapfewse.ocx"(或者可能是 "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapfewse.ocx")。

现在您将能够在对象资源管理器中浏览它(在 VBE 中按 F2),并声明类型。

您现在需要熟悉此库的类型。一些提示,它们都以 Gui 开头,例如 GuiSessionGuiApplicationGuiConnection、GuiBlabla... 名称非常明确和直观。

SAP 还提供有关其 GUI 对象的文档:

补充@Nelson_Vides 所说的内容。正如他所说,你将需要引用sapfewse.ocx文件,你可以通过按F2查看class个对象。

但是,仅当您从 SAP class 库中定义对象后,IntelliSense 才会可见。

Dim userArea As GuiUserArea ' <-- For example

现在,只要使用该对象,就会显示 IntelliSense。

祝你好运,脚本编写愉快!