Hi.
This is my first time posting on this forum so please excuse me if I've done something not quite right it how to do a post.
I'm trying to have my Excel VBA navigate to a particular page of a financial website but am not able to properly click through or select a drop down option on a "hover menu" to get to that page. I've tried to find within the target HTML the list option (using the instr function the only technique that seems to work), but when executing an ".item.click" step control does not seem to progress through to the desired page. The desired page is the "Stocks" page under the "News & Research" heading near the top center of the Fidelity.com home page.
Here is my code (some commented out steps were left in for troubleshooting purposes. For instance item #39 of the collected tags is the menu option link that I wish my code to be able to navigate through to):
-----------------------------------
<code>
----------------------------------------------------------
I've tried to post the underlying HTML that is the target of my code's
navigation but when I preview the post the html displays in browser format i.e. what one would see in browser mode, not source code mode. If someone could also opine on how to paste in HTML source code without it doing this that would helpful too.
So sorry I can't show the HTML code. If you go to the above website mentioned in the code above, look at the source code and search for the link also detailed in my code above you should see the link I'm trying to follow in my code above.</code><code><code></code></code><code><code>
</code></code>
<code><code></code></code><code><code> </code></code>Back to my defective code, I think it is missing something simple but I've not had luck on anything. Ordinarily, I'd just paste the target URL (embedded in the hover menu's options) straight away in my code (and that can be done), but this is part of a larger piece of code I use to log into the site first. I have to manipulate the website buttons internally as a logged in user to get to the data I want (since it's only available to customers like me, who log in frequently for information and research needs).
Any guidance would be appreciated.
Thanks.
This is my first time posting on this forum so please excuse me if I've done something not quite right it how to do a post.
I'm trying to have my Excel VBA navigate to a particular page of a financial website but am not able to properly click through or select a drop down option on a "hover menu" to get to that page. I've tried to find within the target HTML the list option (using the instr function the only technique that seems to work), but when executing an ".item.click" step control does not seem to progress through to the desired page. The desired page is the "Stocks" page under the "News & Research" heading near the top center of the Fidelity.com home page.
Here is my code (some commented out steps were left in for troubleshooting purposes. For instance item #39 of the collected tags is the menu option link that I wish my code to be able to navigate through to):
-----------------------------------
<code>
Code:
Sub navigator()
Dim htmldoc As MSHTML.IHTMLDocument
Dim eleColTags As MSHTML.IHTMLElementCollection
Dim eleTag As MSHTML.IHTMLElement
Dim IE As InternetExplorer
Dim counter As Long
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Top = 0
.Left = 0
.Width = 1000
.Height = 1000
.Visible = True
.navigate "http://www.fidelity.com"
End With
Do While IE.Busy Or IE.readyState <> 4
DoEvents
Loop
With IE.document.all
Set htmldoc = IE.document
Set eleColTags = htmldoc.getElementsByTagName("a")
For Each eleTag In eleColTags
'If counter = 39 Then
'counter = counter
'End If
'Debug.Print counter, eleTag
If InStr(eleTag, "https://eresearch.fidelity.com/eresearch/landing.jhtml") > 0 Then
'try to click through this menu choice and this link
With eleColTags
.Item.Click
End With
Exit For
End If
counter = counter + 1
Next
End With
End Sub
I've tried to post the underlying HTML that is the target of my code's
navigation but when I preview the post the html displays in browser format i.e. what one would see in browser mode, not source code mode. If someone could also opine on how to paste in HTML source code without it doing this that would helpful too.
So sorry I can't show the HTML code. If you go to the above website mentioned in the code above, look at the source code and search for the link also detailed in my code above you should see the link I'm trying to follow in my code above.</code><code><code></code></code><code><code>
</code></code>
<code><code></code></code><code><code> </code></code>Back to my defective code, I think it is missing something simple but I've not had luck on anything. Ordinarily, I'd just paste the target URL (embedded in the hover menu's options) straight away in my code (and that can be done), but this is part of a larger piece of code I use to log into the site first. I have to manipulate the website buttons internally as a logged in user to get to the data I want (since it's only available to customers like me, who log in frequently for information and research needs).
Any guidance would be appreciated.
Thanks.
Last edited by a moderator: