首页 > 解决方案 > 编写脚本时出现活动内容错误

问题描述

在 SAP 中编写脚本时出现活动内容通知的问题。我的 IE 的 ActiveX 设置被设置为允许 ActiveX 内容。仅当通过脚本设置 SAP 连接时才会出现问题。以下是我遇到问题的代码部分。通过脚本打开也会导致显示不同的 SAP 视图,这可能是问题的一部分。是否有其他方法可以打开 SAP 以避免活动内容通知?

'***** Open SAPGUI
Set objShell = CreateObject("WScript.Shell")
objShell.exec "C:\Program Files (x86)\SAP\frontend\sapgui\saplgpad.exe"
Application.Wait (Now + TimeValue("0:00:03"))
On Error Resume Next

Set fso = CreateObject("Scripting.FileSystemObject")
Set Application1 = CreateObject("Sapgui.ScriptingCtrl.1")
Set SAPGUI = GetObject("SAPGUI")

'***** Start Script Engine (disable pop up in SAP settings if applicable or will get error)

Set Application1 = SAPGUI.GetScriptingEngine
  If SAPguiAPP Is Nothing Then
    Set SAPguiAPP = CreateObject("Sapgui.ScriptingCtrl.1")
  End If
  If Connection Is Nothing Then
    Set Connection = SAPguiAPP.OpenConnection("1C. SAP ECC Production")
  End If

  If Session Is Nothing Then
    Set Session = Connection.Children(0)
  End If

标签: vbasap

解决方案


推荐阅读