Hi there,


I want a macro that goes to a website and clicks a button and downloads an excel file and then I want to copy it into my current file to manipulate.


Sub DownloadFile()
Dim myURL As String
myURL = "___://seb-fa-applications/FAApplica...intenance.aspx" **got rid of http to post**
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False, "username", "password"
WinHttpReq.send
myURL = WinHttpReq.responseBody
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.responseBody
oStream.SaveToFile "P:\SEB Vals\Valuations Team\Reg Reporting\AccountDetails_20141008090126(1).xls", 2 ' 1 = no overwrite, 2 = overwrite
oStream.Close
End If
ThisWorkbook.FollowHyperlink "P:\SEB Vals\Valuations Team\Reg Reporting\AccountDetails_20141008090126(1).xls"


End Sub


This works wonderfully except it downloads the url which I know is correct in the code but I need to go an extra step as on the URL you need to click 'export to excel' button to download the file.


The relevant HTML code is (I think!!):


<td style=" text-align: center; font-size: 12px;">
<input type="submit" name="ctl00$ContentPlaceHolder1$btnExportToExcel" value="Export To Excel" id="ctl00_ContentPlaceHolder1_btnExportToExcel" class="Loginbtn" style="width:191px;" /></td>


thanks in advance of any help.


Noreen (New User )