0

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?

Jason Bayldon
  • 1,296
  • 6
  • 24
  • 41

2 Answers2

3

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

Tim Williams
  • 154,628
  • 8
  • 97
  • 125
-1

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

Community
  • 1
  • 1
Mandar
  • 498
  • 1
  • 4
  • 17
  • I am not using Javascript, I am using VBA, with IE, for automation (no access to other browsers). I notice there are a lot of javascript references but not many VBA on the subject. Thanks for the reply, though. – Jason Bayldon Sep 10 '12 at 02:26