VBA MACRO Button click using a class instead of ID

pedrosc

New Member
Joined
Apr 22, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Dear Users,

I am trying to run a sub that does the following:
  1. Access this website (Home - ClinicalTrials.gov)
  2. Introduces some words in the boxes "Condition or disease" and "other terms"
  3. Clicks in the button "search"

I did everything but point 3. I can't do point three because the button does not have an ID but has a class. I tried to use a class but then I can't run the command .Click I don't know exactly why.

Here it is the code I have been using. When I run the macro I keep getting this error: Object does not support this method (this basically is telling me I can.t use the command .click with this getelement...

PS: if you know any good resource for data scrapping please share with me I would be forever grateful


CODE

Sub pullDatafromweb()
Dim IE As Object
Dim doc As HTMLDocument

'initializing the IE'

Set IE = CreateObject("InternetExplorer.Application")

'allows us to see the browser getting launched'

IE.Visible = True

'telling the object to go to the following object'

IE.Navigate "Home - ClinicalTrials.gov"

'tells the system to wait until the page is loaded before moving into the next line'

Do While IE.Busy Or IE.ReadyState <> 4
Application.Wait DateAdd("s", 1, Now)

'puts the specificed values/strings in the search boxed'

Loop
Set doc = IE.document
doc.getElementById("home-search-condition-query").Value = "GvHD"
IE.document.getElementById("home-search-other-query").Value = "MSC"
doc.getElementByTagClass("input.ct-searchButton.hp-searchButtonn").Click

End Sub

END CODE
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Why not try submitting the form that the button you want to click is on?
 
Upvote 0
Why not try submitting the form that the button you want to click is on?
Sorry I am really a begginer so I don't really know what does it mean "form". I am assuming it is this

VBA Code:
<input value="Search" type="submit" class="ct-searchButton hp-searchButton" tabindex="9" title="Search">
<input value="Search" type="submit" class="ct-searchButton hp-searchButton" tabindex="9" title="Search">
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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