putting web address from IE window into data object

L

Larry

Jay Freedman recently showed me how to put the text of the selected
hyperlink in Word into the Clipboard. I realized this code made it
possible to put non-selected material, for example the Full Name of the
document, into the Clipboard. Now I'm wondering if, using this vba
capability, it would be possible to get the web address of, say, the
most recently activated Internet Explorer window and put it into a data
object and thence into the Clipboard? (This would streamline an
existing set of macros I have that opens Word, pastes text I've copied
from a web page into Word and formats that text, then I manually
re-activate the web page to copy its address, then I switch back to word
and run another macro which pastes the address and does further
formatting.)

Larry

Jay Freedman's code

If Selection.Hyperlinks.Count = 0 Then
Exit Sub
End If

Dim MyData As DataObject
Dim strURL As String

strURL = Selection.Hyperlinks(1).Address
Set MyData = New DataObject

MyData.SetText strURL
MyData.PutInClipboard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top