vba - 有谁知道通过 VBA 自动登录 SAP 的连接代码?
问题描述
我在使用 Windows 10 和 VBA 中的连接代码时遇到问题,无法自动打开 SAP、为我登录并开始宏,是否有适用于 Windows 10 的标准代码?
我有旧版本 Windows 的代码,但我不断收到运行时错误,因为它不完全知道安装的新版本 SAP 是什么/在哪里。
If Sheets("Start").Range("E9") = "Yes" Then
On Error Resume Next
Set SapGuiAuto = CreateObject("Sapgui.ScriptingCtrl.1")
On Error GoTo 0
If SapGuiAuto Is Nothing Then
MsgBox "Please start SAPlogon"
Exit Sub
End If
On Error Resume Next
Set SAP_Applic = SapGuiAuto.GetScriptingEngine
On Error GoTo 0
If SAP_Applic Is Nothing Then
MsgBox "Scripting disabled"
Exit Sub
End If
Set Connection = SAP_Applic.OpenConnection("", True) 'Enter your system here
Set session = Connection.Children(0)
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject SAP_Applic, "on"
End If
解决方案
推荐阅读
- python - Codecov 仅运行 .travis.yml 中最后列出的测试
- c# - 无法在数组字符串中找到长字符串 - C#
- python - 如何将可变数量的变量传递给pyspark select表达式
- php - mailchimp api,curl调用掉线的问题
- c++ - 彩色图像的卤化处理平均值
- ruby-on-rails - 包含的子查询上的 Active Record 选择字段
- azure - 使用 terraform 从规模集中删除实例
- ruby-on-rails - Rails NameError 'uninitialized constand User::Events' 使用设计
- php - 如何在 PHP 中多次运行脚本
- c# - 根据公共变量组合来自 2 个对象列表的值