Click Element in Internet Explorer with VBA

4Heads

New Member
Joined
May 20, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I need to click a 3-elipses button/element on a page. It doesn't have the usual ID, Name etc. Once clicked, there is a drop down and I need to click COPY from the drop down. How do I click these elements. Thanks. Here is the code:

Elipses Button HTML
VBA Code:
<span class="more-item-trigger__white cyb-icon-ic_more" _ngcontent-cog-c54=""></span>

Drop down Item HTML
VBA Code:
<span class="action-menu-item__text" style="overflow: hidden; -ms-text-overflow: ellipsis;" _ngcontent-cog-c62=""> Copy </span>

I tried this but the VBE didn't like the last underscore:
VBA Code:
ie.Document.getElementsByClassName("more-item-trigger__white cyb-icon-ic_more" _ngcontent-bfb-c54="")

More of the HTML if it would help.
VBA Code:
<button class="small white--colors small-white more-item-trigger more-item-trigger--colors more-item-trigger--typography more-item-trigger--" aria-label="more items" data-testid="more-actions-button" _ngcontent-mcx-c54="">
<span class="more-item-trigger__white cyb-icon-ic_more" _ngcontent-mcx-c54="">
</span>
</button>
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I tried this but the VBE didn't like the last underscore
Yes 'cause the underscore has nothing to do with the class ‼ :eek:
As obviously the class is colored in orange …​
 
Upvote 0
Welcome!

It looks like your issue is possibly needing some quotes within a string. For that, you need to escape the quotes: Quotation marks in VBA
Thank you. I tried the following. The statement now no longer errors out in the code window, but it doesn't click the ellipses element in IE. Any other suggestions?
VBA Code:
IE.document.getElementsByClassName ("""more-item-trigger__white cyb-icon-ic_more""" & Chr(32) & Chr(95) & "ngcontent-bfb-c54=""""")
 
Upvote 0
Yes 'cause the underscore has nothing to do with the class ‼ :eek:
As obviously the class is colored in orange …​
Thanks, not sure what you mean. Should I get rid of the underscore then? This is my latest code.
VBA Code:
IE.document.getElementsByClassName ("""more-item-trigger__white cyb-icon-ic_more""" & Chr(32) & Chr(95) & "ngcontent-bfb-c54=""""")
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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