Download Files (PDF) from Web

后端 未结 1 1812
星月不相逢
星月不相逢 2021-01-22 14:56

I am fresh-starter at VBA. How do I download PDF file using UrlDownloadToFile from http://cetatenie.just.ro/wp-content/uploads/?

Can anybody help with this? The code is

相关标签:
1条回答
  • 2021-01-22 15:18

    Sorry - I should have guessed that URLDownloadToFile was an API call and could have answered the whole question at SQL "%" equivalent in VBA.

    Remove the function named URLDownloadToFile completely. Paste this at the top of the module where your Sample procedure is

    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
    

    Now change that one line in Sample to look like this

    Ret = URLDownloadToFile(0, sUrl & hAnchor.pathname, sPath & hAnchor.pathname, 0, 0)
    

    Then you should be good to go. If you want some different file name, then you'll have to code some logic to change it at each iteration.

    0 讨论(0)
提交回复
热议问题