Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

instantiating an acroreader document open in ie 1

Status
Not open for further replies.

ChrisNome

IS-IT--Management
Mar 22, 2011
47
0
0
US
hi

does anyone know how to instantiate an acrobat reader document that's open in internet explorer? I just want to grab it and save it with VBA. Any ideas

CN
 
try
Code:
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
   Private Const ERROR_SUCCESS As Long = 0
Public Function DownloadFile(Source, des) As Boolean
  
  'if the API returns ERROR_SUCCESS (0),
  'return True from the function
   DownloadFile = URLDownloadToFile(0&, Source, des, 0&, 0&) = ERROR_SUCCESS
   
End Function
[code]
source = URL to pdf 
des = path to save pdf
 
Thanks PWise

I have to tell you, I'm kind of lost with API's. I don't know what most of this means, but I tried it and had it messagebox the result of the downloadfile function. Came back as false and no PDF in the destination folder. I passed both des, Source as strings.

I don't know if this has anything to do with it or not, but the reason I want to access the PDF from an embedded adobe reader is that the PDF is only available if the user has a VPN connection activated when clicking the link that goes to the PDF. If he/she has the VPN active, internet explorer then opens the PDF in an embedded player. When I tested it I had the VPN open, the PDF open in internet explorer (in an embedded player) and used the ie URL of the adobe reader with the opened PDF as the Source.

Any recommendations? Thanks for the help and it was pretty exciting to see it do something after trying to use the adobe internet controls in VBA and having it do nothing.

CN
 
..oops, i just put in a path, not a filename

true - it worked it downloaded something :)

Alright, came back true but didn't produce the result I wanted:
I tried the name "test.pdf" and the "save as" filename itself (when clicking save manually within the embedded reader) and got the same error when trying to open it:

that it is either not correct or damaged. It's only 8 kbytes so obviously it didn't pull the PDF

If I don't designate the file type in "des" then it says it's an "X File". Also the link property of the linking pointing at the PDF is an X/PDF file

Any thoughts?
 
Code:
Sub download()
Dim Source
Source = "[URL unfurl="true"]http://nds1.nokia.com/files/support/nam/phones/guides/Nokia_5130_XpressMusic_UG_en-US_es-LAM.pdf"[/URL]
msgbox downloadfile(Source, "c:\5130.pdf")
End Sub

i had to download today a service guide for a cell phone i used the above code and it put the pdf on my c:\drive

how were you calling the downloadfile function
 
i called it similar to you, but that wasn't the problem. It was the pathname, I was sending the page the PDF was embedded in (which is apparently an X file, haha) instead of the PDF itself. I looked in the source and found an iframe tag with ID="PDF", and used the src property of that as the path.

It works like a charm. I'd recommend it for any file download. Thanks a lot man.

Still don't know why it doesn't always return 0 though, the way it's written, but whatever. I don't get that API stuff, but it seems to work really well so I wish i did.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top