【问题标题】:Error in execution of SAP Scritping with VBA使用 VBA 执行 SAP 脚本时出错
【发布时间】:2018-09-27 11:13:59
【问题描述】:

我正在尝试使用 vba 执行 SAP 脚本,但它显示以下错误 "集合的枚举找不到指定索引的元素"

我尝试了一些解决方案,但到目前为止没有任何效果? 在 sap 中录制脚本的按钮完全空白,不知从何而来。

【问题讨论】:

    标签: excel vba sap


    【解决方案1】:

    我使用下面的代码,您只需将 OpenConnection 命令更改为我将使用的“SAP 程序”,在这种情况下我使用的是 R/3 PCL nuevo

    Shell "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", vbHide
    Set WSHShell = CreateObject("WScript.Shell")
    
    Do Until WSHShell.AppActivate("SAP Logon ")
    T0 = Timer
    Do
    Delay = Timer - T0
    Loop Until Delay > 1 'tempo pra abrir o sap
    Loop
    
    Set WSHShell = Nothing
    
    If Not IsObject(appl) Then
    Set SapGuiAuto = GetObject("SAPGUI")
    Set appl = SapGuiAuto.GetScriptingEngine
    End If
    If Not IsObject(Connection) Then
    Set Connection = appl.OpenConnection("R/3 PCL nuevo", True)
    End If
    
    If Not IsObject(session) Then
    Set session = Connection.Children(0)
    End If
    If IsObject(WScript) Then
    WScript.ConnectObject session, "on"
    WScript.ConnectObject appl, "on"
    End If
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-16
      • 1970-01-01
      • 1970-01-01
      • 2022-10-24
      • 2022-01-17
      • 1970-01-01
      • 2019-08-15
      相关资源
      最近更新 更多