Jason Bayldon
Jason Bayldon

Reputation: 1296

how to use .getelementbyID and copy inner html - VBA

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

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?

Upvotes: 0

Views: 19236

Answers (2)

Tim Williams
Tim Williams

Reputation: 166146

You can get the innerHTML like this:

TxtHtml = .getElementById("elementId").InnerHtml

You can then set the clipboard text from VBA: http://word.mvps.org/faqs/macrosvba/ManipulateClipboard.htm

Upvotes: 3

Mandar
Mandar

Reputation: 498

Use JQuery to access innerHtml or Html whatever you want.

var textToCopy = $(#ReturnValue).innerHtml();

For copying text to clipboard, you can refer Copy / Put text on the clipboard with FireFox, Safari and Chrome

Upvotes: -1

Related Questions