Saving a pdf web page not working

Smudgeroonie

New member
Local time
Today, 21:39
Joined
Mar 16, 2016
Messages
3
Morning All,

Please excuse me if this is the wrong forum (long time user, first time poster) but the problem I'm having is occurring within a module in Access where I look for a pdf link within a web page, navigate to that web page and then save it (using the function URLDownloadToFile) as a pdf file.

I'm having trouble with getting Adobe Reader to recognise a file I've saved using various methods in vba.

Although it appears that the file is saved correctly (i.e. as a pdf format), when I try to open the file to view, it produces an error (format not recognised).

I have tried other (coded) methods for downloading the file, but all seem to produce the same (incorrect) results.

Any advise would be gratefully received.
 
Many Thanks for the quick response.

However, this coding does not work the way I need either.

Yes, it saves the file with the filename specified to the location specified but when I go to the specified location, via Windows Explorer, and click on the saved pdf file, I receive the following error message (from Adobe Reader XI):-

Adobe Reader could not open 'MyFile.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).

If I were to open the URL and use the save function of Internet Explorer (CTRL+S) using the predefined filename and location, then everything opens properly.

Any ideas?
 
SOLVED.

Perhaps I should have mentioned that the web page being downloaded was from a client area which requires a username and password combination to log-in.

Therefore, when I tried to open the saved pdf, it was attempting to open the file as the saved url i.e. it required username and password for loading the saved pdf under the specified url (using Hexedit to open the file led me to this conclusion).

My workaround consisted of navigating to the specified url, whilst still in the coding, and using SENDKEYS (I'm sure there are other ways which I'd be glad to hear) to save the file as a pdf with the specified filename and location.

Although not pretty, it does work. Result.:):):)
 

Users who are viewing this thread

Back
Top Bottom