通过 Excel VBA 连接 SAP

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41543972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 11:50:26  来源:igfitidea点击:

Connect SAP Through Excel VBA

excelvbasap

提问by user7383845

I have no direct SAP installed on my machine and using SAP window through below link.

我的机器上没有直接安装 SAP,并通过以下链接使用 SAP 窗口。

https://nedc-ctx.applications.services.axa-tech.intraxa/Citrix/AccessPlatform/auth/loggedout.aspx

https://nedc-ctx.applications.services.axa-tech.intraxa/Citrix/AccessPlatform/auth/loggedout.aspx

I am aware of Record and Run function of SAP GUI and that is working. I have this access in training version only. In production I am unable to use run and record option.

我知道 SAP GUI 的记录和运行功能并且正在运行。我仅在培训版本中具有此访问权限。在生产中,我无法使用运行和记录选项。

How do I open SAP window from Excel VBA, connect and load the data?

如何从 Excel VBA 打开 SAP 窗口,连接并加载数据?

In example given on link below I get an error.

在下面链接中给出的示例中,我收到一个错误。

Excel VBA pulling data from SAP NetWeaver

Excel VBA 从 SAP NetWeaver 中提取数据

I found I am unable to add reference file "sapfewse.ocx" on my machine.

我发现我无法在我的机器上添加参考文件“sapfewse.ocx”。

Is it possible to connect SAP through Excel VBA if we access SAP through above provided link. After clicking on above link new pop-up window will get connected with SAP with window. SAP is getting connected through Citrix.

如果我们通过上面提供的链接访问 SAP,是否可以通过 Excel VBA 连接 SAP。单击上面的链接后,新的弹出窗口将通过窗口与 SAP 连接。SAP 正在通过 Citrix 建立联系。

Code from the help link.

来自帮助链接的代码。

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
session.StartTransaction "SE16"

回答by JoseS

The code you provided would only work if you have the SAP GUI installed on your computer. I would suggest asking the IT team if they can provide you the server address so you can use a Remote Function Call to retrieve the data automatically. This can be done with VBA (https://archive.sap.com/discussions/thread/129358) You would need to adapt the code in the link to match your needs

您提供的代码仅在您的计算机上安装了 SAP GUI 时才有效。我建议询问 IT 团队他们是否可以为您提供服务器地址,以便您可以使用远程函数调用来自动检索数据。这可以通过 VBA ( https://archive.sap.com/discussions/thread/129358) 完成您需要调整链接中的代码以满足您的需求