vba findById 方法中的返回类型,无法通过 id 找到控件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23043020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 02:45:33  来源:igfitidea点击:

Return type in findById method, control could not be found by id

vbaaccess-vbasap

提问by Roberto Milani

I'm writing a VBA script that read some values from a SAP procedure (ME23N).

我正在编写一个 VBA 脚本,它从 SAP 过程 (ME23N) 中读取一些值。

I'm using findById method to read some values but I dont know if the object extists or not.

我正在使用 findById 方法读取一些值,但我不知道该对象是否存在。

Session.findById("wnd[0]/usr/sub/.......).Text

I'd like to know what findById method returns if the provided id does not exists. Knowing that I can handle this situation and avoid "The control could not be found by id" runtime message.

如果提供的 id 不存在,我想知道 findById 方法返回什么。知道我可以处理这种情况并避免“ID 无法找到控件”运行时消息。

Is there a public SAP documentation where I can find some informations?

是否有公共 SAP 文档可以在其中找到一些信息?

Thanks in advance

提前致谢

回答by Pavle Stojanovic

Is this something that youare asking ? This is whati use .....

这是你要问的吗?这是我用的......

' bottom left where is displays the errors or message saying you dont have access to the transaction

' 左下角显示错误或消息,指出您无权访问交易

On Error Resume Next session.findById("wnd[0]/.....SetFocus 'or .Text

On Error Resume Next session.findById("wnd[0]/.....SetFocus 'or .Text

If session.findById("wnd[0]/sbar").Text = "The control could not be found by id." Then Debug.Print "transaction not found."

如果 session.findById("wnd[0]/sbar").Text = "无法通过 id 找到控件。" 然后Debug.Print“没有找到交易”。

session.findById("wnd[0]").Close ' closing SAP Window \ Program. session.findById("wnd[1]/usr/btnSPOP-OPTION1").press ' press the yes \ok button to close SAP Exit Sub End If

session.findById("wnd[0]").Close ' 关闭 SAP Window \ Program。session.findById("wnd[1]/usr/btnSPOP-OPTION1").press ' 按下 yes \ok 按钮关闭 SAP Exit Sub End If