Internet Explorer Macro Question

tycanis

New Member
Joined
Mar 14, 2011
Messages
12
I am trying to access drop down menus on a webpage through a macro. I have a macro where I am able open the correct website. I cannot directly open the website that the dropdown menu redirects you to because it does not have a different web address. Any ideas on how to access dropdowns in Internet Explorer through a macro? Thanks
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
Can you post your current code and the URL for the page with the dropdowns on it?

It should be possible to write code to select from the dropdowns but the code could differ depending on how the page has been created/designed.
 

tycanis

New Member
Joined
Mar 14, 2011
Messages
12
Here is the code and what I think each part does. I am new to macros and self teaching myself so go easy if I have something wrong. I cannot post the webpage url because it is a company webpage and can only be accessed through internal computers. Hope this helps.

Sub DoBrowse1()
Dim ie As SHDocVw.InternetExplorer
Dim btnDropDown As MSHTML.HTMLInputElement
Dim ieDoc As MSHTML.HTMLDocument
Dim btnSubmit As MSHTML.HTMLInputElement
Set ie = New SHDocVw.InternetExplorer
'Opens webpage
ie.Navigate ""
'Wait until page is loaded
Do Until ie.readyState = READYSTATE_COMPLETE: Loop
ie.Visible = True
'Get Document object
Set ieDoc = ie.Document
'Try to select the dropdown. This does not work here.
Set btnDropDown = ie.all.DropDowns("Drop Down 1").ListIndex = 11
Set btnSubmit = ie.all.Item("Go")

End Sub
 

tycanis

New Member
Joined
Mar 14, 2011
Messages
12
Alright. I figured out a way around this. Now I need to try to make a webquery where the web address changes. What I have is a web address that increases incrementally with the date. I know what the address will be everyday but I do not know how to work this into a webquery in a macro. Any ideas? Thanks
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
Sorry, know next to nothing about webqueries.

Why not start with the macro recorder? That's where I would start.

By the way it should be SelectedIndex, and there aren't any DropDown objects.

You were heading in the right direction though by getting a reference to the document.

That could be used to get references for the comboboxes, buttons etc, perhaps with something like GetElementByID.:)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,015
Messages
5,834,939
Members
430,327
Latest member
Mr_Himalayan778

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top