Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 22002

InternetExplorer Selection

$
0
0
I'm trying to access an Internet Explorer session via Excel VBA. I want to select a bunch of text and links in IE, then use that selection with Excel VBA to populate the sheet.

Namely, I want to obtain the "selected" links. I figured since it's easy to obtain the collection of links in a HTML document, then getting the "selected" links would be easy. Also, I can get the "selection" object of the HTML Document, however it's not returning any text.

However, what I can't seem to figure out is what are the selected hyperlinks. I tried to use this to get the selected text, then filter on link collection, but my Selection Object is showing empty. Maybe you forum members know a way to get the collection of selected hyperlinks.


Code:

Dim IE As InternetExplorer
Set IE = New InternetExplorer
With IE
    .Navigate "http://www.randomsite.tv"
  Do Until IE.ReadyState = READYSTATE_COMPLETE: Loop
End With
IE.Visible = True

MsgBox "Wait. Select HTML text. Click OK."

Dim IEDOC 'As HTMLDocument
Set IEDOC = IE.Document
Dim IEDocLinks 'As DispHTMLElementCollection
Set IEDocLinks = IEDOC.Links ' '
Dim IESel
Set IESel = IEDOC.Selection
Dim SelText
Set SelText = IESel.createRange '.Text


Viewing all articles
Browse latest Browse all 22002

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>