0

I'm trying to click on a button on a webpage via a VBA excel script, but I'm getting runtime errors when using the below code:

objIE.document.getElementById("e-actions-commonmasthead-mail").Click

The element I'm trying to get from the page is listed with the following HTML:

<td id="e-actions-commonmasthead-mail"
    class="s-cell-center s-toolbarcell-left s-toolbar-text s-toolbarcell-selected" 
    title="Mail" toolbarside="left" toolbarindex="0" 
    com_ibm_dwa_ui_toolbar_overflowed="false"

 onmouseover="AAA.DSq.EKc.prototype.EYl['e-actions-commonmasthead:Ebx'].EEu(event, this);"
  onmouseout="AAA.DSq.EKc.prototype.EYl['e-actions-commonmasthead:Ebx'].EEu(event, this);"
     onclick="AAA.DSq.ELU(event, 'e-actions-commonmasthead', 'Gqj', {area:'mail'});" 

  unselectable="on" style="-moz-box-sizing:border-box;-webkit-user-select:none;">

<img align="center" border="0" width="16" height="16" 
     id="e-actions-commonmasthead-mail-icon" 
     class="s-toolbaricon-notext" 
     src="/iNotes/Forms9.nsf/transparent.gif?OpenFileResource&amp;MX&amp;TS=20160816T154745,21Z" 
     xoffset="" yoffset="" 
     style="background-image: url(&quot;/iNotes/Forms9.nsf/sprite_masthead.png?OpenFileResource&amp;MX&amp;TS=20160816T154745,21Z&quot;); 
            background-position: -17px 0px;">
</td>

I've tried both Click and FireEvent "onclick" and they give me runtime errors.

3
  • What are the errors you're getting though? Commented Oct 30, 2017 at 3:30
  • I'm getting Run Time error '424', Object required. Commented Oct 30, 2017 at 3:40
  • Check each of the objects in the line of code you posted to see which one is Nothing. Posting a bit more code would be useful. Commented Oct 30, 2017 at 3:43

1 Answer 1

1

Ok I figured it out. I need to call the onclick script manually via below code:

 Call objIE.document.parentWindow.execScript("AAA.DSq.ELU(event, 'e-actions-commonmasthead', 'Gqj', {area:'mail'})", "JavaScript")   

Thanks for all the help and hints!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.