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
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,831
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
75,831
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.:)
 

Watch MrExcel Video

Forum statistics

Threads
1,108,969
Messages
5,525,959
Members
409,673
Latest member
Riseee

This Week's Hot Topics

Top