Macro to Download, Open and Copy Excel Data from internet link to another excel file

noreendeasy

New Member
Joined
Jul 16, 2014
Messages
32
Hi there,

I was wondering how to go about downloading an excel file from an IE Link (it's an inside lan link which only works on site so won't be able to share that with you).

I have pasted the link into the file so all the macro has to do is click the link and it will take you there.

I have tried recording a macro but it doesn't work, here is the macro:
<CODE> Sub FA_Download_Funds()
'
' FA_Download_Funds Macro
'
'
Range("A1").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Windows("Download Funds.xlsx").Activate
End Sub

</CODE>

When I run this code, nothing happens it just takes me to the link.

I would like the macro to download the data (I click a link on the Internet Link) to 'Export to Excel', it then downloads a 'Read Only' Copy. I would then like the macro to copy this downloaded data to my current spreadsheet where the macro is.

Is this possible?

Thanks in advance of any help​
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi there,

I got this macro to work for this

Range("A1").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Windows("Download Funds.xlsx").Activate
Sheets("AccountDetails").Select
Range("A1").Select
ActiveSheet.Paste
Except it doesn't copy the data over from the file. It only copies what's copied in the clipboard.

How do I get it to copy the downloaded file? I have tried using 'Windows("AccountDetails_20141008073904(1).xls").Activate' but I got a run time error '9'.

Thanks in advance
 
Upvote 0
Hi,

I've been searching online for a solution for this and I found this:

<CODE>Sub DownloadFile()
Dim myURL As String
myURL = "http://seb-fa-applications/FAApplicationManager/AccountMaintenance.aspx"

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

</CODE>
<CODE>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.

Could anyone help please</CODE>
 
Upvote 0
Can anyone help today please? I need to get the code to click a button and then copy the downloaded file?

Thanks

PS I think it's very unfair that there's a rule of not posting in other forums if this one is no help?? Shouldn't it be allowed if I don't get a response?
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,700
Members
448,979
Latest member
DET4492

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