【发布时间】:2019-07-25 14:30:14
【问题描述】:
这是我的 VBA 代码:
子 logowanie()
UserForm1.显示
vSAP = Shell("C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", vbNormalFocus)
调用 Shell("C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", vbNormalFocus)
设置 WSHShell = CreateObject("WScript.Shell")
直到 WSHShell.AppActivate("SAP Logon")
Application.Wait Now + TimeValue("0:00:01")
环形
设置 SapGui = GetObject("SAPGUI")
设置 Appl = SapGui.GetScriptingEngine
Application.Wait Now + TimeValue("0:00:01")
设置连接 = Appl.Openconnection("xxxxxxxxxx", True)
Application.Wait Now + TimeValue("0:00:02")
WSHShell.SendKeys UserForm1.TextBox1.Value
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys UserForm1.TextBox2.Value
WSHShell.SendKeys "{ENTER}"
Application.Wait Now + TimeValue("0:00:01")
WSHShell.SendKeys "y_ecd_96000032"
WSHShell.SendKeys "{ENTER}"
Application.Wait Now + TimeValue("0:00:01")
WSHShell.SendKeys "{DOWN}"
WSHShell.SendKeys "{DOWN}"
WSHShell.SendKeys "{DOWN}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "22:00:00"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "*"
WSHShell.SendKeys "{ENTER}"
Application.Wait Now + TimeValue("0:00:02")
WSHShell.SendKeys "DC15"
Application.Wait Now + TimeValue("0:00:02")
WSHShell.SendKeys "{ENTER}"
Application.Wait Now + TimeValue("0:00:02")
WSHShell.SendKeys "{DOWN}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{ENTER}"
Application.Wait Now + TimeValue("0:00:02")
WSHShell.SendKeys "^{TAB}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{ENTER}"
Application.Wait Now + TimeValue("0:00:02")
WSHShell.SendKeys "U:\[...]\a.txt"
WSHShell.SendKeys "{ENTER}"
Application.Wait Now + TimeValue("0:00:03")
WSHShell.SendKeys "{F8}"
Application.Wait Now + TimeValue("0:00:03")
WSHShell.SendKeys "{F8}"
Application.Wait Now + TimeValue("0:00:03")
WSHShell.SendKeys "+{F4}"
Application.Wait Now + TimeValue("0:00:02")
WSHShell.SendKeys "U:\[...]\SRET.xlsx"
WSHShell.SendKeys "{ENTER}"
'Application.Wait Now + TimeValue("0:00:03")
WSHShell.SendKeys "{LEFT}"
WSHShell.SendKeys "{ENTER}"
Application.Wait Now + TimeValue("0:00:04")
应用激活 (vSAP)
Application.Wait Now + TimeValue("0:00:02")
WSHShell.SendKeys "%{F4}"
Application.Wait Now + TimeValue("0:00:02")
WSHShell.SendKeys "{TAB}"
WSHShell.SendKeys "{ENTER}"
结束子
我需要 Application.Wait Now + 命令之间的 [某个时间值]。但有时它不起作用,当 SAP 工作太慢时。怎么做?当每个对话框窗口出现时,我需要一些带有 Application.Wait 的循环。
【问题讨论】: