小编Ani*_*han的帖子

在Excel VBA中禁用SAP登录弹出窗口

我有一个VBA代码,有助于登录SAP.代码工作正常但我在建立连接时收到警告弹出窗口.

在此输入图像描述

我需要绕过或禁用此警告弹出窗口.我写了代码,但它没有用.请帮助

Sub code1()
If Not IsObject(SAPguiApp) Then
    Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If

If Not IsObject(Connection) Then
    Set Connection = SAPguiApp.OpenConnection("********", True)
End If

If Not IsObject(Session) Then
    Set Session = Connection.Children(0)
End If
If Session.ActiveWindow.Name = "wnd[1]" Then
    If Session.findbyid("wnd[1]").Text Like "A script*" Then Session.findbyid("wnd[0]/usr/btnSPOP-OPTION1").press
End If

Session.findbyid("wnd[0]/usr/txtRSYST-MANDT").Text = "103"
Session.findbyid("wnd[0]/usr/txtRSYST-BNAME").Text = "*****"
Session.findbyid("wnd[0]/usr/txtRSYST-LANGU").SetFocus
Session.findbyid("wnd[0]/usr/txtRSYST-LANGU").caretPosition = 2
Session.findbyid("wnd[0]").sendVKey 0

Session.findbyid("wnd[0]/tbar[0]/okcd").Text = "/nsu01"
Session.findbyid("wnd[0]").sendVKey 0
Session.findbyid("wnd[0]").maximize

End Sub
Run Code Online (Sandbox Code Playgroud)

请注意:我知道可以在SAP GUI中禁用此弹出窗口但不支持这样做,因为它可能会在将来导致安全威胁.请通过以下代码帮助建议:

如果Session.ActiveWindow.Name ="wnd 1 "那么如果Session.findbyid("wnd 1 ").Text如"A script*"Then Session.findbyid("wnd [0]/usr/btnSPOP-OPTION1").按万一

excel vba excel-vba

3
推荐指数
1
解决办法
879
查看次数

标签 统计

excel ×1

excel-vba ×1

vba ×1