trying to click a button within one of several tabs within an ie webpage using vba

Status
Not open for further replies.

upton

New Member
Joined
Sep 23, 2013
Messages
2
Hi,

I am having trouble figuring out how to use vba to automate clicking a button that is located with one of a set of tabs in a web page. I used inspect element in firefox to figure out the element id for the button i want to click (which is "runscreen" but i cannot find this element id when viewing the actual web page's source code, also the button shares this element id with another button on another tab. Both buttons have the same “run” as their innertext but have different element hid’s. I can’t figure out why the element id is viewable by inspecting the button but is not viewable by selecting to view the webpage’s source code either with ie or firefox. The only part of the webpage’s code that seems to me hidden is the part that deals with the elements within the tabs. I think it may have something to do with
img src="/images/new/ajax-loader-trans.gif"

I first tried this code:
'IE.document.getElementById("runscreen").click

the vba returned an error "object required", i am guessing because the element id is not directly on the web page source code but hidden somehow

then i tried
Call IE.document.parentWindow.execScript("runscreen()", "JavaScript")

i think the page is somehow using a function when the button is clicked but i can't figure out if this is the case or not.
I have been searching all over for a solution to clicking the button but have been unable to figure it out. any help would be greatly appreciated.

here is the code i find when i use firefox to inspect the element i'm trying to click (but this code is not visible when i select view source in ie/firefox):

here is the code i find when i use firefox to inspect the element i'm trying to click (but this code is not visible when i select view source in ie/firefox):

<a id="runScreen" class="general-button general-button-green help-enabled" href="javascript: void(jsScreen.runScreen(true));" onfocus="blur();" hid="screen-rules-run">
<span>
Run
</span>
</a>
And here is more of the surrounding code (only the first line of this code which I bolded is viewable when viewing the web page source code)
<div id="screentabcontent" class="tabs-nav-content ui-corner-bottom">
<div id="freeform-cont">
<div class="vocab-ref"> … </div>
</div>
<div id="screen-criteria-section">
<div id="commonCont">
<div id="commonButtons" style="padding-bottom:4px; float:left; "> … </div>
<div style="text-align:right">
<span class="parameterTitle"> … </span>
<span class="parameterValue"> … </span>
<span style="padding-left: 10px">
<a id="runScreen" class="general-button general-button-green help-enabled" href="javascript: void(jsScreen.runScreen(true));" onfocus="blur();" hid="screen-rules-run">
<span> … </span>
</a>
</span>
<span style="padding-left: 5px"> … </span>
<span id="universeTotal" class="universe-subtotal"> … </span>
</div>
<div id="commonRules" style="clear:both; zoom: 1"> … </div>
</div>


and here is the code for the tabs that is viewable when I select view source in ie/firefox, the button i'm trying to click is in the "rules" tab which has the element id "scrtab_1" :
<div id="screentabs" style="zoom: 1;">


<div class="tabs-nav">
<table cellpadding="0" cellspacing="0" border="0"><tr>
<td class="toggle-width"><a href="javascript:void(jsScreen.toggleWide());" onfocus="blur()"><img id="toggleScrWidth" src="
/images/new/width-wide.gif" width="16" height="16" border="0" title="Toggle Display Width" alt=""/></a></td>
<td ><a id="scrtab_0" class="scr-tab-link help-enabled" hid="screen-about-user" href="javascript: void(0);" onfocus="blur()">About</a></td>
<td ><a id="scrtab_5" class="scr-tab-link help-enabled" hid="screen-notes" href="javascript: void(0);" onfocus="blur()">Notes</a></td>

<td ><a id="scrtab_7" class="scr-tab-link help-enabled" hid="screen-notes" href="javascript: void(0);" onfocus="blur()">Main Settings</a></td>

<td class="on"><a id="scrtab_1" class="scr-tab-link help-enabled" hid="screen-rules" href="javascript: void(0);" onfocus="blur()">Rules</a></td>

<td ><a id="scrtab_6" class="scr-tab-link help-enabled" hid="screen-hedge" href="javascript: void(0);" onfocus="blur()">Hedge Rules</a></td>
<td ><a id="scrtab_2" class="scr-tab-link help-enabled" hid="screen-results" href="javascript: void(0);" onfocus="blur()">Results</a></td>
<td ><a id="scrtab_3" class="scr-tab-link help-enabled" hid="screen-backtest" href="javascript: void(0);" onfocus="blur()">Backtest</a></td>
<td ><a id="scrtab_4" class="scr-tab-link help-enabled" hid="screen-advancedbacktest" href="javascript: void(0);" onfocus="blur()">Advanced Backtest</a></td>

</tr></table>
</div>


<div id="screentabcontent" class="tabs-nav-content ui-corner-bottom"><div align="center"><img src="/images/new/ajax-loader-trans.gif" alt="loading"></div></div>
</div>
</div>

</div>
</center>
</div>





 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Status
Not open for further replies.

Forum statistics

Threads
1,223,631
Messages
6,173,465
Members
452,516
Latest member
archcalx

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