PDA

View Full Version : Accessing files on webpage



mctabish
11-04-2009, 10:18 AM
I am new to working with web sites from VBA, so please assume I know nuthin'
I have been learning a lot and now I at a point where I have not been able to find the answer...
The site I am using is on a corporate intranet. I am trying to download a generated file (xls worksheet, developed based on a submition of data, so the "file" does not exist until I click the link. I can not use the
Workbooks.Open Filename:="http://www.xxxxxxx.com/zzz.xls"
I have gotten to the point where I get to the site, I file in all of the data needed, then click on the "export to excel" link. I am now not able to go further.
I am presented with a "Download File" dialog with the open, save as or cancel buttons
I would like to be able to select "SAVE AS" and then fill in the path and file name then save the file.
Here is the calling portion of the web

<div style="text-align:right; font-size:xx-small; padding-right:10px;">
<input type="image" name="ctl00$mainContent$imgExport" id="ctl00_mainContent_imgExport" src="Images/xls.gif" style="border-width:0px;" />
<a id="ctl00_mainContent_lnkExport" href="javascript:__doPostBack('ctl00$mainContent$lnkExport','')">Export to XLS</a>
&nbsp;&nbsp;&nbsp;
<span id="ctl00_mainContent_lblRecords">[Click Search to View Records]</span>
</div>

and here is my code that I have to click on the link

Sub GetEquipList(EAS As Object)
Do While True
tPage = EAS.document.DocumentElement.outerHTML
If InStr(EAS.document.DocumentElement.outerHTML, "Export to XLS") > 0 Then
With EAS.document.aspnetForm 'document name = "EAS" form name = "aspnetForm"
Set ELEMENTCOL = EAS.document.getElementsByTagName("a")
tester = VarType(ELEMENTCOL)
itm = 1
x = 1
For Each link In ELEMENTCOL
If tester = VarType(ELEMENTCOL) Then
Debug.Print link.innerHTML

If link.innerHTML = "Export to XLS" Then
link.Click
' here is where I am stuck....I need too click on "Save As" and then save the file from a "File Download"
Exit For
' MsgBox "Assigned Complete"
End If
x = x + 1
End If
Next link
End With
Else
Exit Do
End If
Loop
End Sub

What do I need to do to get this working?:dunno
TIA
Bruce