如何使用.getelementbyID和复制内部html - VBA [英] how to use .getelementbyID and copy inner html - VBA
问题描述
所以我设置了对Microsoft HTML对象库和Microsoft Internet控件的引用,并且通过获取元素id来输入值的示例如下:
So I have set up my references to Microsoft HTML Object Library and Microsoft Internet controls, and an example to input a value by getting an element id is below:
With HTMLDoc
.getElementById("USER").setAttribute "value", "myuser"
.getElementById("PASSWORD").setAttribute "value", "mypass"
.getElementById("Button").Click
End With
令人好奇的是,我想知道有一个名为ReturnValue的ID标签,其中包含一个我想要复制到剪贴板的内部html中的字符串,我将如何使用.getElementByID和COPY在这种情况下?
What Im curious to know, is, lets say there was an ID tag named "ReturnValue" that contained a string in the inner html that I wanted to copy to clipboard, how would I use .getElementByID and COPY in that instance?
推荐答案
你可以得到这样的innerHTML:
You can get the innerHTML like this:
TxtHtml = .getElementById("elementId").InnerHtml
然后,您可以从VBA设置剪贴板文本: http://word.mvps.org/常见问题/米acrosvba / ManipulateClipboard.htm
You can then set the clipboard text from VBA: http://word.mvps.org/faqs/macrosvba/ManipulateClipboard.htm
这篇关于如何使用.getelementbyID和复制内部html - VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!