在VBA中自动为SAP Business Objects登录Web服务

时间:2016-04-19 23:35:17

标签: vba web-services excel-vba business-objects excel

是否可以使用Excel中的Analysis for Microsoft Excel COM加载项自动登录SAP Business Objects Web服务?当我运行我的代码时,我看到下面的“登录到SAP BusinessObjects BI平台”窗口,要求用户手动输入他们的Web服务凭据(注意:这些与他们的SAP凭据不同)。理想情况下,我可以在没有任何用户交互的情况下设置所有字段(用户,密码,Web服务URL,系统和身份验证)。

Web Service Logon Window

我正在尝试使用VBA代码自动刷新连接到SAP Business Objects的Excel工作簿。通过查看SAP上可用的开发人员文档(请参阅here),我能够自动执行大多数命令。还有一个命令“SAPLogon”,但这只能提供SAP登录凭据,而不是Web服务凭证。

我的代码示例如下:

'Refresh dashboard
LResult = Application.Run("SAPExecuteCommand", "PauseVariableSubmit", "Off")
LResult = Application.Run("SAPSetRefreshBehaviour", "On")
LResult = Application.Run("SAPExecuteCommand", "Refresh")
If LResult = 0 Then
    'Refresh failed. Exit with error.
    StrMsg = "Unable to retrieve variables or refresh any data; script will now exit.  Please close Excel, open a new instance of Analysis for Microsoft Excel, and try again."
    LogMsg StrMsg
    MsgBox StrMsg
    GoTo Exit_UpdateDashboard
End If

在执行这段代码之前,我希望自动化用户登录。我已经对此进行了广泛的研究,但找不到任何通过VBA自动登录Web服务的例子。到目前为止我尝试过的一些链接是:

1 个答案:

答案 0 :(得分:1)

我不认为这是可能的,因为提供的连接Web服务的库仅用于.Net和Java。我试图从WSDL构建SOAP信封,但从未设法使其工作。但是,使用SDK中的库相对容易。我曾经在CShap中为Excel构建了一个插件来直接从Excel管理和刷新报表:https://code.google.com/archive/p/bo-utils/