Accessing Web page through VBA, not able to execute javascript, need to click image button

Mintx

New Member
Joined
Apr 8, 2011
Messages
7
I need to click a image button on web page which will download the report to excel. There is a javascript which does this, but I have no luck in executing the script, it says some error

Html:
a name="exportdlg" id="exportdlg" href="javascript:docCrystalEvent('doc', 'tb=exportdlg')" >img border=0 name="exportdlgImage" id="exportdlgImage" width=22.0px height=22.0px src='../../viewers/crystalreportviewers115/images/toolbar/export.gif' alt="Export this report" title="Export this report" ***********="this.src='../../viewers/crystalreportviewers115/images/toolbar/export_over.gif'"

VBA code:
objIEReportWindow.document.parentWindow.execScript "docCrystalEvent('doc', 'tb=exportdlg');"
here i m getting error 'Could not perform operation due to error 80020101'

another way i tried to access the image button is
For Each Element In objIEReportWindow.document.getElementsByTagName("a")
MsgBox (Element.innerText) 'to see if i get the required element
'If Element.Value = "Exportdlg" Then Element.click = True
Next

But still no luck yet, this is really getting into my nerves, as I've almost completed the entire automation but stuck here @ the end.

Any help would be highly appreciated...
Thanks in advance
 
Last edited:

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi Andrew,
Really appreciate your quick reponse.

this code dosen't work for me
'****************************
Dim i As Integer
Dim cImgs
Set cImgs = objIEReportWindow.document.images
For i = 0 To cImgs.Length - 1
MsgBox (cImgs(i).src)
If cImgs(i).src Like "*export.gif" Then
cImgs(i).parentElement.Click
End If
Next i
'***************************

dont know the reason why, but it dosent even enter into the loop.
I tried the same code for some other html pages, it really worked fine, but for the page which i need to retrive the information from, it dosent work at all.
 
Last edited:
Upvote 0
It dooes contain many images/gifs (highlighted in red below), please refer the source code below, would not be able to post the entire source code, as its a internal business system, & security issue
------------------------------------------
starts with:
Rich (BB code):
HTML
HEAD




<FORM id=docCrystalForm method=post name=docCrystalForm action=../../viewers/rpt/DHTMLViewer.jsp?skin=skin_default&lang=en&sViewerName=doc&id=CUID,ok2eyswACt0MB5sAMzKFbn35cWU&sDocName=untitled&sRepoTyp e=10&sType=rpt&&iDocID=ok2eyswACt0MB5sAMzKFbn35cWU&sIDType=CUID&iDocID=ok2eyswACt0MB5sAMzKFbn35cWU&currReportID=1623835 p <>



<FORM id=docCrystalForm encType="application/x-www-form-urlencoded;charset=utf-8" method="post" action="../../viewers/rpt/DHTMLViewer.jsp?skin=skin_default&lang=en&sViewerName=doc&id=CUID,ok2eyswACt0MB5sAMzKFbn35cWU&sDocName=untitled&sRepoTyp e=10&sType=rpt&&iDocID=ok2eyswACt0MB5sAMzKFbn35cWU&sIDType=CUID&iDocID=ok2eyswACt0MB5sAMzKFbn35cWU&currReportID=1623835" name="docCrystalForm">



<FORM id=docCrystalForm encType="application/x-www-form-urlencoded;charset=utf-8" method="post" action="../../viewers/rpt/DHTMLViewer.jsp?skin=skin_default&lang=en&sViewerName=doc&id=CUID,ok2eyswACt0MB5sAMzKFbn35cWU&sDocName=untitled&sRepoTyp e=10&sType=rpt&&iDocID=ok2eyswACt0MB5sAMzKFbn35cWU&sIDType=CUID&iDocID=ok2eyswACt0MB5sAMzKFbn35cWU&currReportID=1623835" name="docCrystalForm">
<FORM id=docCrystalForm method="post" action="../../viewers/rpt/DHTMLViewer.jsp?skin=skin_default&lang=en&sViewerName=doc&id=CUID,ok2eyswACt0MB5sAMzKFbn35cWU&sDocName=untitled&sRepoTyp e=10&sType=rpt&&iDocID=ok2eyswACt0MB5sAMzKFbn35cWU&sIDType=CUID&iDocID=ok2eyswACt0MB5sAMzKFbn35cWU&currReportID=1623835" name="docCrystalForm" enctype="application/x-www-form-urlencoded;charset=utf-8">
<FORM id=docCrystalForm encType="application/x-www-form-urlencoded;charset=utf-8" method="post" action="../../viewers/rpt/DHTMLViewer.jsp?skin=skin_default&lang=en&sViewerName=doc&id=CUID,ok2eyswACt0MB5sAMzKFbn35cWU&sDocName=untitled&sRepoTyp e=10&sType=rpt&&iDocID=ok2eyswACt0MB5sAMzKFbn35cWU&sIDType=CUID&iDocID=ok2eyswACt0MB5sAMzKFbn35cWU&currReportID=1623835" name="docCrystalForm">
some code in between
'
'
'

the code which I'm concerntrating on, i.e the export button, below
Rich (BB code):
</TD>
<TD nowrap width="2.0px"></TD><TD nowrap valign="center">
alt="Print this report" title="Print this report" ***********="this.src='../../viewers/crystalreportviewers115/images/toolbar/print_over.gif'" **********="this.src='../../viewers/crystalreportviewers115/images/toolbar/print.gif'" >
</TD>
<TD nowrap width="2.0px"></TD><TD nowrap valign="center">
--------------------------------------------------------------------
One thing is running in my mind is, this page is a DHTML viewer[1] as it says, on the notepad title of the source code when i right click & open the view source.

Not much sure about this, is it that this dosen't come under the standard. I've declared the variable as Dim objIEReportWindow As InternetExplorer
Even I've set the focus on this page inorder to play around with it.

Post doing this, not sure why its not picking up any images from it. It might be something to do with the web page type, I may be wrong....
</FORM>.
 
Last edited by a moderator:
Upvote 0
I'm finding it tough to post the code, not sure how to put it across, as its not been aligned in the required manner once posted

code for your reference

starts here:
HTML:
some code in between
 
 
 
 
 
 
 
 
 
 
[code] 








[IMG]http://www.mrexcel.com/forum/../../viewers/crystalreportviewers115/images/toolbar/export.gif[/IMG]


[IMG]http://www.mrexcel.com/forum/../../viewers/crystalreportviewers115/images/toolbar/print.gif[/IMG]










</DIV></FORM>
 
Upvote 0
I've got some clue on the issue. Actually the report page which I'm trying to access is crystal reports, which is embeded in HTML format.

Not sure if this is impacting
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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