我需要在我的宏中写什么来整理 SAP 中的突然提示?

What do I need to write in my macro to sort through sudden prompts in 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 在可能发生或不发生的代码行之后解决了它。