【问题标题】:how to choose SAP system by VBA如何通过VBA选择SAP系统
【发布时间】:2017-10-19 12:49:46
【问题描述】:

我已经挖掘了整个互联网,但没有找到类似的东西。

我正在编写将数据从 SAP 提取到 Excel 的 VBA 程序,一切顺利。我想自动化整个过程并通过VBA打开Sap Logon这不是问题,但是在我们公司有很多基于SAP的系统,所以在打开SAP Logon和授权之间有一个窗口我应该选择一个服务器(截屏)。你知道如何通过 VBA 自动选择服务器吗?

非常值得关注。

【问题讨论】:

    标签: vba sap


    【解决方案1】:

    我使用下面的代码来选择SAP系统。

    Sub Choose_SAP(system_SAP As String, userSAP As String, passwordSAP As String)                                                                    
    
         Dim APP As Variant                                             
         Dim SapGuiAuto As Variant                                      
         Dim Connection As Variant                                      
         Dim session As Variant                                            
    
         Set SapGuiAuto = GetObject("SAPGUI")
    
         Set APP = SapGuiAuto.GetScriptingEngine
    
         Set Connection = APP.OpenConnection(system_SAP , True)
    
         Set session = Connection.Children(0)
    
         session.FindById("wnd[0]").maximize
         session.FindById("wnd[0]/usr/txtRSYST-BNAME").Text = userSAP
         session.FindById("wnd[0]/usr/pwdRSYST-BCODE").Text = passwordSAP
         session.FindById("wnd[0]/tbar[0]/btn[0]").press
    End Sub
    

    我希望这对你有用!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-28
      • 1970-01-01
      • 1970-01-01
      • 2020-04-06
      • 2020-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多