markb
07-10-2014, 02:44 PM
New to this forum, and would appreciate any help with using VBA to update a dropdown menu on a web page. I have scoured the internet without success.
I have written some code to download Excel files from a Medicare website. It contains links to several Excel files, and my code will read the links, download the files, process them in Excel and then import them into the website. The problem is that on that site there is a dropdown menu for the user to choose how many files to list (10, 25, 50 or 100). The default is 10, and I want to get all 100. I can modify the value of the dropdown menu (see my code below), but I can't figure out how to get the page to update. There is no "Go" button, and the page that lists 100 files does not have a unique URL.
Here is my code. If you access the page and change the dropdown menu, you will see that it automatically updates the page. How can I accomplish that with VBA? I am using IE 8, and I have tried using .FireEvent("onchange") and .FireEvent("onclick") without success. *** I seem unable to post the link because I have not yet posted at least five times to the site. Not sure how to solve this one......****
Public Sub GetFiles()
Dim MyURL As String
MyURL = ""
Set MyBrowser = New InternetExplorer
With MyBrowser
.Silent = True
.navigate MyURL
.Visible = True
Do
DoEvents
Loop Until .readyState = READYSTATE_COMPLETE
Set HTMLDoc = .Document
HTMLDoc.getElementById("selectNumOfRows").Value = "100"
End With
End Sub
I have written some code to download Excel files from a Medicare website. It contains links to several Excel files, and my code will read the links, download the files, process them in Excel and then import them into the website. The problem is that on that site there is a dropdown menu for the user to choose how many files to list (10, 25, 50 or 100). The default is 10, and I want to get all 100. I can modify the value of the dropdown menu (see my code below), but I can't figure out how to get the page to update. There is no "Go" button, and the page that lists 100 files does not have a unique URL.
Here is my code. If you access the page and change the dropdown menu, you will see that it automatically updates the page. How can I accomplish that with VBA? I am using IE 8, and I have tried using .FireEvent("onchange") and .FireEvent("onclick") without success. *** I seem unable to post the link because I have not yet posted at least five times to the site. Not sure how to solve this one......****
Public Sub GetFiles()
Dim MyURL As String
MyURL = ""
Set MyBrowser = New InternetExplorer
With MyBrowser
.Silent = True
.navigate MyURL
.Visible = True
Do
DoEvents
Loop Until .readyState = READYSTATE_COMPLETE
Set HTMLDoc = .Document
HTMLDoc.getElementById("selectNumOfRows").Value = "100"
End With
End Sub