VBA - Website Search Bar with weird name

excelaudio

New Member
Joined
Nov 4, 2015
Messages
8
https://www.cms.gov/medicare-coverage-database/search/advanced-search.aspx

Hello all,

I'm trying to automate going to the above site for a simple search feature in Excel and the name of the search bar comes back with a really long name. Is the name truly as long as it states or am I missing something? I have attached my VBA code as well so I an get his macro moving forward.

Code:
Sub Test()
Dim appIE As Object
'Set appIE = Nothing
Dim objElement As Object
Dim objCollection As Object

Set appIE = CreateObject("InternetExplorer.Application")
sURL = "[URL]https://www.cms.gov/medicare-coverage-database/search/advanced-search.aspx[/URL]"
With appIE
    .Navigate sURL
    .Visible = True
End With
Do While appIE.Busy 'Or appIE.ReadyState <> 4
    DoEvents
Loop
Set objCollection = appIE.Document.getElementsByTagName("[LEFT][COLOR=#222222][FONT=Consolas]ctl00_ctl00_ctl00_CMSGMainContentPlaceHolder_ToolContentPlaceHolder_MCDContentPlaceHolder_pnlSearchByID[/FONT][/COLOR][/LEFT]")


Set appIE = Nothing
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Yes, it's that long, but that's the id of the 'SEARCH BY ID' button, not its tag name. Therefore you want getElementById.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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
Back
Top