【问题标题】:How check if exists the field? SAP GUI Scripting如何检查该字段是否存在? SAP GUI 脚本
【发布时间】:2014-05-12 19:44:19
【问题描述】:

如何检查字段是否存在? 我试过了:

If session.findById("wnd[1]").setFocus Then

【问题讨论】:

    标签: sap-gui


    【解决方案1】:

    你可以试试以下:

    on error resume next
    session.findById("wnd[1]").setfocus
    if err.number = 0 then
       msgbox "The SAP GUI element exists."
    else
       msgbox "The SAP GUI element does not exist."
    end if
    on error goto 0
    

    问候, 脚本人

    【讨论】:

      【解决方案2】:

      如果问题是如何查看是否有第二个窗口:wnd[1]

      这应该有效:

      Sub test()
      
          If session.Children.Count = 2 then
              'your code goes here
      
          End If
      End Sub
      

      它还有一个优点是不需要使用错误处理来工作,
      因此可能会发生另一种类型的错误,但仍会得到处理。

      【讨论】:

        【解决方案3】:

        为避免使用错误处理,您可以使用:

        If Not session.findById("wnd[1]", False) Is Nothing Then
            session.findById("wnd[1]").setFocus
        End If
        

        这里的关键是 FindById 中的第二个参数,它确定是否存在 SAP 中的字段或任何对象是否引发错误。如果设置为 False,则不会引发错误,并且对象设置为 Nothing,您可以在我的代码中进行检查。

        【讨论】:

          猜你喜欢
          • 2023-04-07
          • 1970-01-01
          • 1970-01-01
          • 2018-11-13
          • 1970-01-01
          • 2018-12-17
          • 2015-11-27
          • 2012-10-17
          • 1970-01-01
          相关资源
          最近更新 更多