Save PDF files directly from hyperlink without opening individually

harshjo

New Member
Joined
Jul 9, 2012
Messages
1
I have a large number of forms that are all organized in MS Excel. These forms are updated fairly often and I need to download the new updates when this happens. Each row has it's own hyperlink associated to the pdf document online. Currently I have to click each link which opens the file in IE. From there I have to save each file individually to a local location. This process takes a considerable amount of time so I was hoping to automate it. Below is code I have found on this forum used for another application and tried to modify it to the best of my ability. FYI this is an embedded hyperlink.

When I go line by line and watch either strTEXT or strURL, it is pulling in the correct hyperlink.

example link: https://www.mysite.com/thunder.pdf
hopeful file saved: c:\thunder.pdf

Option Explicit
Sub Save()
Dim HL As Excel.Hyperlink
Dim ws As Excel.Worksheet
Dim strURL As String
Dim strText As String
Dim FSO As Object
Dim ts As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
Set ws = ActiveSheet
For Each HL In ws.Hyperlinks
strURL = HL.Address
ie.navigate strURL
Do Until ie.readystate = 4
DoEvents
Loop
strText = ie.document.body.innertext
Set ts = FSO.createTextfile("C:\" & HL.Name)
ts.Write strText
ts.Close
Next HL
End Sub

My program stops on the red line above with the following message.
Run-time erroe '438': Object doesn't support this property or method.

Am I on the right path?

Thanks
Josh
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,215,972
Messages
6,128,016
Members
449,414
Latest member
sameri

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