VBA controls for IE and clicking buttons on a page

ozborn

New Member
Joined
Oct 10, 2016
Messages
6
Hi,

So i have been searching hundreds of forum threads for an answer to this, but its been convoluted due to the website layout that i am working with.

I have code that goes to a website and needs to click on a button, but the button doesnt seem to have the same labels that i normally see in HTML.



here are the html attributes i have been scanning through to figure out how to call the button to click it with VBA controls.


<button data-onboarding="new-object-button" data-selenium-test="new-object-button" type="button" aria-disabled="false" class="btn uiButton private-button private-button--default private-button--primary btn-primary add-obj" tabindex="0"><!-- react-text: 9679 -->Add contact<!-- /react-text --></button>
" button data-onboarding="new-object-button" data-selenium-test="new-object-button" type="button" aria-disabled="false" class="btn uiButton private-button private-button--default private-button--primary btn-primary add-obj" tabindex="0"><!-- react-text: 9679 -->Add contact<!-- /react-text -->

some additional html associated with this button:

div class="m-left-3 UIColumn-content"><div class="add-control"





I dont know if it has something to do with Selenium (which i dont use and not samilar with).
Here is the macro that i have been attempting to play with.
my issue is that i cant figure out how to use the right command to click the button (there doesnt seem to be a proper ID).


Code:
Sub FillInBBCSearchForm()
'Make sure you've set a reference to the
'Microsoft Internet Controls object library first
'create a variable to refer to an IE application
Dim ieApp As New SHDocVw.InternetExplorer
'make sure you can see this new copy of IE!
ieApp.Visible = True
'go to the website of interest
ieApp.Navigate "https://app.hubspot.com/sales/xxxxxxx/contacts/list/view/all/?"
Do While ieApp.Busy
DoEvents
Loop
'wait for page to finish loading
Do While ieApp.Busy And Not ieApp.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop


'wait for page to finish loading
Do While ieApp.Busy And Not ieApp.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop


Application.Wait (Now + #12:00:05 AM#)
'ieApp.Document.all.Item("search").Value = "bob"
'click on the search button
ieApp.Document.all("button").Click
End Sub





any help would be greatly appreciated!!!
pretty please.</div>
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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