Results 1 to 2 of 2

Thread: VBA - Website Search Bar with weird name
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Nov 2015
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA - Website Search Bar with weird name

    https://www.cms.gov/medicare-coverag...ed-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 = "https://www.cms.gov/medicare-coverag...ed-search.aspx"
    With appIE
        .Navigate sURL
        .Visible = True
    End With
    Do While appIE.Busy 'Or appIE.ReadyState <> 4
        DoEvents
    Loop
    Set objCollection = appIE.Document.getElementsByTagName("
    ctl00_ctl00_ctl00_CMSGMainContentPlaceHolder_ToolContentPlaceHolder_MCDContentPlaceHolder_pnlSearchByID
    ") Set appIE = Nothing End Sub

  2. #2
    Board Regular
    Join Date
    Oct 2007
    Posts
    5,684
    Post Thanks / Like
    Mentioned
    7 Post(s)
    Tagged
    2 Thread(s)

    Default Re: VBA - Website Search Bar with weird name

    Yes, it's that long, but that's the id of the 'SEARCH BY ID' button, not its tag name. Therefore you want getElementById.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •