# Access VBA FollowHyperlink to PDF document: Acrobat opens but then closes immediately



## Gregor1234 (Jun 3, 2004)

In my Access database (Office 2003, Windows XP) each record is associated with a file somewhere on disk. Some of these files are MS Word files and some are PDF files.

In the DB, the user has the option to click on a button to view the document.

When the user clicks on "View Document, I use the 
Application.FollowHyperlink method to open the document file.

This works well except in the case of one particular computer where Adobe Acrobat is installed (instead of the usual Adobe Reader).

When I run the software on this computer, the Word document open correctly but when I try to FollowHyperlink to a PDF file, the document opens momentarily, then closes almost immediately. The document is in view for less than a second. 

There is nothing wrong with the PDF document itself. When opened in the normal way on this computer, Acrobat opens it properly with no warnings or dialogues.

I am unsure whether the problem has anything to do with Acrobat versus Reader but it is the single difference that I can identify immediately. I will soon try this on other machines that also have Acrobat installed to see if the problem is the same on those machines. 

Any ideas?


----------



## OBP (Mar 8, 2005)

I don't think it has anything to do with Reader vs Acrobat as I only have Reader and it does exactly the same. To overcome this I use an OLE object for PDF files.
I have created a similar database to yourself which opens most types of files including
Excel, Word, PDF, Music, Video, HTM, HTML.
It populates the Tables directly from a Folder/Directory either with all files of the type chosen or single files.
It also has a "Text" search facility for looking in Doc, RTF, TXT, ASC, PDF and XLS files.
You are welcome to a copy if you want.
Perhaps you could evaluate it for me as I intend offering it or versions of it free on a few websites. I would like to know if it is useful or not.


----------



## Gregor1234 (Jun 3, 2004)

I'm not sure I understand how you use an OLE object for PDF files and would like to learn. 

I would be happy to look at you database. Can you attach a Zip of it here?


----------



## OBP (Mar 8, 2005)

Gregor, this is a copy of my Document management database.

It is not finished yet as I still need to add a Search Form to search the Document Table for matches in Descriptions, Speciality and "Used for" fields etc.

This came about after another poster asked if I new of any software that did this and I realised I really need this to keep control of the Access Databases that I have helped with over the last few years, there are now over 300 of them alone. I also have Excel Workbooks from here as well, along with various pieces of useful VBA code.

I would very much appreciate any feedback that you or any else can give me as it is really just a group of ideas at the moment.
Obviously any "business" oriented versions would not need "music" files etc.

I forgot in the previous post that you can also store Web Links as well, but you have to copy and paste them in.


----------



## Gregor1234 (Jun 3, 2004)

Sorry-

I've been very busy of late and hadn't time to reply 

I opened your datasbase but I can't run the code. Apparently it requires quite a few libraries to handle all of the different types of files and I don't have quite a few of them.

I do however get the idea behind it just by looking at the forms and code and I think the concept behind the DB is an interesting idea. 

As for opening PDF files, you appear to be storing them as objects and activating them with library routines. This is the sort of thing that I'm not sure I want to do. I've been given to understand (thought I've not tested it myself) that storing objects in tables requires significantly more space than storing the bytes of files. The customer want the DB to have as small a footprint as possible. In addition, and perhaps more importantly, I cannot ensure that the user will have any of the required libraries/library versions installed. They may have Acrobat or they may have Adobe Reader or may have some other PDF reader installed. Using the "Follow" method allows me to let the system resolve how to open the file (with the problems that that entails). If I use "Follow" the user can at least open the file manually if necessary as it is written to disk. If I use routines out of a specific library then they won;'t even be able to open the DB is the correct library/version is not present.

Thanks anyway for the info. I will still be interested in taking a longer look at the code in your document management database.


----------



## slurpee55 (Oct 20, 2004)

OBP, I used to have a copy of this (when you posted it before) and wanted to fiddle with it again, but the zip file is password protected, at least that's what my PC thinks.


----------



## OBP (Mar 8, 2005)

Gregor, you only "store" one .pdf file and it gets over written by each new one.
You should be able to set all of the library references to run it.

slurpee, this version is a slightly later one than the previous post.


----------



## Gregor1234 (Jun 3, 2004)

I see... I hadn't read far enough into the code to grasp that you only "stored" a file as it was being displayed.

In the end, I opted for a different solution... I set up a different form with a Microsoft Web Browser control on it and use that to display the PDF file. This works well enough and again, it offloads the problem of exactly "how" to display the file to the system.


----------

