如何在vba中使用发送密钥到文本框? [英] How do I use send keys to a textbox in vba?

查看:89
本文介绍了如何在vba中使用发送密钥到文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在自动化网页。更新文本框时,会在该文本框中按下某个键。但我正在通过vba中的代码直接处理文本框中的值。所以值得注意更新。



我试过sendkeys。但它不起作用。给出错误。代码如下:



iItems.SendKeys{L}



错误:对象没有这个属性或方法。

请给我一些解决方案。



谢谢

推荐答案

无论 iItems 对象是什么,它没有SendKeys方法,所以你得到了这个错误。



SendKeys是一个独立的功能。你只需删除 iItems。部分,你就不会再出现这个错误。



但是,SendKeys众所周知是不可靠的。您无法直接控制哪个控件获取这些键。即使用户在代码运行时点击其他内容(最常见的问题!)也会搞砸并将密钥发送到他们点击的任何内容。你无法控制它。
Whatever that iItems object is it doesn't have a SendKeys method so you're getting that error.

SendKeys is a stand-alone function. You just remove the iItems. part and you won't get that error any more.

But, SendKeys is notoriously unreliable. You have no direct control over which control gets those keys. Even the user clicking on something else (the most common problem!) while your code is running will screw up and send your keys to whatever they clicked on. You cannot control this.


这篇关于如何在vba中使用发送密钥到文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆