Download PDF file form IE URL

sudharshan86

New Member
Joined
May 26, 2014
Messages
13
I need to download .PDF files from url.

I tried the below code and it is not working.

Code:
Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
    "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
    szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long


Sub Test()
    Dim strPDFLink As String
    Dim strPDFFile As String
    Dim Result As Boolean
    strPDFLink = "http://www.bnpparibasmf.in/Uploads/D...ds/Requirement under PMLA Act 2002 and Rules frame thereunder.pdf"
    strPDFFile = "Requirement under PMLA Act 2002 and Rules frame thereunder.pdf"
    Result = DownloadFile(strPDFLink, strPDFFile)
    MsgBox Result
End Sub


Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then DownloadFile = True
End Function

can someone help.

Script referred from http://www.mrexcel.com/forum/excel-questions/740193-visual-basic-applications-download-pdf-url.html
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I see two problems.
1. "..." in strPDFLink.
2. No drive or path in strPDFFile.
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,099
Members
452,301
Latest member
QualityAssurance

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