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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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,213,536
Messages
6,114,202
Members
448,554
Latest member
Gleisner2

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