vba - SAP GUI 脚本在保存时处理两个可能的弹出窗口
问题描述
为采购订单 (PO) 的价格更新创建脚本。
如果我尝试更新的价格在采购订单上已经相同,则会出现问题。然后没有任何东西可以保存,信息弹出窗口出现,说“没有数据更改”。这是脚本停止工作的地方,因为脚本的录制基于新价格不同并且可以保存。
我试图将 if 语句添加到代码中,但它不起作用。新价格不同时不保存,需要保存。它总是选择 Enter 并且不使用 Else 语句。
session.findById("wnd[0]/tbar[0]/btn[11]").press 'Save on Menu bar
If session.ActiveWindow.Name = "wnd[1]" Then
If session.findById("wnd[1]").text = "Information" then
session.findById("wnd[1]/tbar[0]/btn[0]").press 'If popup and it's only Information type press Enter
objSheet.Cells(i, 3).Value = "No data changed" 'Information that no change has been done
Else
session.findById("wnd[1]/usr/btnSPOP-VAROPTION1").press 'Save in the popup window
objSheet.Cells(i, 3) = "Updated" 'Information that the new price has been updated
End if
解决方案
通过删除If session.ActiveWindow.Name = "wnd[1]" Then
脚本可以正常工作
If session.findById("wnd[1]").text = "Information" then
session.findById("wnd[1]/tbar[0]/btn[0]").press 'If popup and it's only Information type then press Enter
objSheet.Cells(i, 3).Value = "No data changed" 'Information that no change has been done
Else
session.findById("wnd[1]/usr/btnSPOP-VAROPTION1").press 'Save in the popup window
objSheet.Cells(i, 3) = "Updated" 'Information that the new price has been updated
End if
推荐阅读
- list - Dart 如何克隆地图列表
- python-3.x - 如何使用python解决具有递归约束的非线性动态优化
- python-3.x - 拟合多标签文本分类模型时的错误
- go - 转到通道未接收/打印发送到通道的最后一个值
- python-3.x - 命令行操作无法解析 f-string 和 python 3 打印参数
- c# - 如何在 .net framework 4.7 上使用 Mediatr 进行集成测试?
- arrays - 如何将 YAML 的子集转换为关联数组的索引数组?
- php - 将 Bootstrap 模式中表单中的信息保存到 PHP 会话中
- java - 平面 XML 到层次结构 XML
- json - 即使返回 HTTP 200,也不会调用 AJAX 成功函数