问题描述
为采购订单 (PO) 的价格更新创建脚本。
如果我尝试更新的价格在 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 = "@R_911_4045@ion" then
session.findById("wnd[1]/tbar[0]/btn[0]").press 'If popup and it's only @R_911_4045@ion type press Enter
objSheet.Cells(i,3).Value = "No data changed" '@R_911_4045@ion 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" '@R_911_4045@ion 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