Hi All,
I am trying to download about 250 hyperlinks to .pdfs. Obviously, this is a very tedious process if done manually so I am trying to automate it using VBA. I tried URLDownloadtofile but it doesn't correctly download the page so that I can open it. I think the reason with this has to do with the fact that the site has to authenticate. So, I've trying the XMLHTTP approach. I figured I'd first try to find some code that works for this purpose and then modify it to suit my needs. So far I have something that I found online (btw, couldn't use hyperlinks because I have fewer than 5 posts apparently) :
Sub Save()
SaveWebFile "I would have the hyperlink in here", "C:\blahblah"
End Sub
Function SaveWebFile(ByVal vWebFile As String, ByVal vLocalFile As String) As Boolean
Dim oXMLHTTP As Object, i As Long, vFF As Long, oResp() As Byte
Set oXMLHTTP = CreateObject("msxml2.xmlhttp")
oXMLHTTP.Open "GET", vWebFile, False
oXMLHTTP.send
oResp = oXMLHTTP.ResponseBody
vFF = FreeFile
If Dir(vLocalFile) <> "" Then Kill vLocalFile
Open vLocalFile For Binary As #vFF
Put #vFF, , oResp
Close #vFF
Set oXMLHTTP = Nothing
End Function
However, when I run it, I get the following error "Run-time error '75': Path/File access error. Can someone please explain why that is the case and what I can do to remedy the problem?
I guess, ultimately, I am not married to using the above process, but from what I understand it one of the ways to authenticate to a website, right? Thank you for your help!