vba - 我需要在宏中写什么来对 SAP 中的突然提示进行排序?
问题描述
所以我有一个更新 SAP 价格的宏。它逐个单元格复制并按顺序执行更新顺序,但有时,在执行更新并保存订单以使用下一行之后,SAP 中会出现提示,我需要单击是或否,或接受/拒绝。
然后我的宏停止,因为它没有一行代码可以对其进行操作。我确实知道需要哪一行,但我的问题是如何编写一行代码,如果出现提示则将执行该代码行?
请记住,有时它会弹出,有时不会。
这是我的代码:
Public sessioninfo As SAPFEWSELib.GuiSessionInfo
Public Sub fastPFI()
Dim ws As Worksheet
Dim App As SAPFEWSELib.GuiApplication
Dim sor As Long
Dim maxsor As String
'HOEEUBV2 (EUB with scripting)
Set GuiAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object
Set App = GuiAuto.GetScriptingEngine 'Get the currently running SAP GUI
Set Con = App.Children(0) 'Get the first system that is currently connected
Set session = Con.Children(0) 'Get the first session (window) on that connection
Set sessioninfo = session.Info
Set ws = Excel.ThisWorkbook.Worksheets("system")
sor = 2
maxsor = ws.Cells(Rows.Count, 1).End(xlUp).Row
'maxsor = 3
Do While sor < maxsor + 1
session.StartTransaction "va02"
'session.FindById("wnd[0]").SendVKey 0
session.FindById("wnd[0]/usr/ctxtVBAK-VBELN").Text = Cells(sor, 1)
session.FindById("wnd[0]").SendVKey 0
session.FindById("wnd[1]").SendVKey 0
session.FindById("wnd[0]").SendVKey 30
session.FindById("wnd[0]").SendVKey 11
session.FindById("wnd[0]/usr/lblRV45S-BSTNK").SetFocus
session.FindById("wnd[0]/usr/lblRV45S-BSTNK").CaretPosition = 18
'session.FindById("wnd[0]").SendVKey 0
sor = sor + 1
Loop
MsgBox "All proformas have been created" & vbNewLine & "Click OK to close file"
' Application.DisplayAlerts = False
'ActiveWorkbook.Close Savechanges:=False
'Application.DisplayAlerts = True
End Sub```
解决方案
On Error GoTo Next
在可能或不会发生的代码行解决了它之后。
推荐阅读
- java - 无法通过 Jenkins 中的 Selenium Maven 使用 GeckoDriver Firefox 建立到 WindowServer 的默认连接
- email - 从旧的临时邮箱中获取电子邮件
- python - 在python中更改字符串列表
- android - 单击主屏幕时禁用应用程序图标
- ios - 如何以编程方式更改 statusBarStyle?
- javascript - 使用 javascript:如何创建一个警报窗口来显示提交的表单值?
- heroku - 手动部署和配置 App 后创建 Heroku App.json
- go - 改变我在合并排序中对通道的使用会杀死我的程序;或者我在处理 goroutine 时误解了范围?
- javascript - React - 在同一个文件中导出多个类
- jquery - ParseXML 不返回内容,控制台显示:(e){return k.each(this,e)