Opening an attached pdf file

rfear

Registered User.
Local time
Today, 22:08
Joined
Dec 15, 2004
Messages
83
What I want to do is 'click' a command button on a form and have a pdf file come up as an example of how the form should be completed.

I have the form, the command button, and an empty vba routine. I have a table with the pdf file in it ( OLE object ).

What I'm missing is the piece of code that will open the pdf file.

Sounds easy enough but I can't find any references on how to do it. Even if the field was added to my query ( that the form is based on ) and the control were invisible I would still have to open the file somehow ???
 
I just store the path to the file and use FollowHyperlink or Shell to open them. See if one of those works for you.
 
That would be fantastic if the pdf file I wanted was resident on somebodys PC, securely rooted in a network folder or otherwise external to MSAccess. As this database could end up going anywhere, the pdf is resident in the database. So I need to reference the location within MSAccess, which is an OLEobject in a table.

I've come up with a solution, it's just not very good.

I've used a bound object frame on a subform to reference the attached pdf file from the table. I've placed this sub form onto my tab control in the main form and made the sub form control look like a button.

Hey presto, pdf file opens.

I'm sure there must be a better way ? I did try adding the OLEObject to my query in order to reference it directly but got an error "ambiguous term ..." or something like that so the query would not run.
 
Simple Software Solutions

I have the exact solution, but I have to go out now will be back pm and will post then.

CodeMaster::cool:
 
Excellent, no rush - got plenty of more coding to do before the database is complete. :)
 
Simple Software Solutions

Back Now,

Here is the link. It comes in the way of a sample mdb.

Any questions, get back to me.

David
 

Attachments

Thanks, however the files are still located outside of the database - the file locations are c:\ ... etc.

My pdf is embedded in the database, in a table, as an OLEobject, which is where I want to pull up the file from.
 
Simple Software Solutions

Here is a module that you wil need to insert into your database

The main routines you will need are FileToBlob and BlobToFile

Code:
 BlobToFile rs("fldDocument"), ssHomeFolder & rs("fldDocumentName"), rs("fldDocument").ActualSize

And use the find files module to open the PDF's

David
 

Attachments

I just store the path to the file and use FollowHyperlink or Shell to open them. See if one of those works for you.

Hi I'm fairly new to MS Access and am having difficulty finding the code for this on the web OR in my MS Access 2003 Step by Step book..

Can anyone tell what the code would like to have a button open a PDF file stored on a network folder? What would the FollowHyperlink code look like?

thanks
G
 
Generally,

Application.FollowHyperlink "c:\whatever.pdf"

You can find more info in VBA Help.
 
Thanks pbaldy,

I have the PDF opening now, but there is a Warning message "Hyperlinks can be harmful to your computer and data. To protect your computer, click only those hyperlinks from trusted sources. Do you want to continue?"

Is there a way to code so this Warning message does not appear?

thanks
 
Sorry one more thing:

Is there a way to code it so the PDF pops up in Print mode?

If its overly complicated I won't bother but just thought I'd ask!

thanks again
 
Thanks pbaldy,

I have the PDF opening now, but there is a Warning message "Hyperlinks can be harmful to your computer and data. To protect your computer, click only those hyperlinks from trusted sources. Do you want to continue?"

Is there a way to code so this Warning message does not appear?

thanks

By entering a direct path for my Hyperlink - "C:\folder\folder\doc.pdf" the Warning message no longer appears.

However if anyone knows of the code to have the PDFs appear in Print Mode that would still be greatly appreciated!

cheers,
G
 
Hi

I have just joined and have a similar issue with PDF's

Within my existing database I can find and open a selected PDF file from a specific location but what I really want / need to do is.


Select the PDF file from the Drop Down List (I can do this)
Open / Print the PDF / Close PDF Viewer (as a silent, automatic process)


I have searched the Internet but have not found anything specific to help

Regards
Kevin
 
This is tested on all versions except 2007. Copy both mdbs into the same folder and open up the EmbeddedObjects.mdb

This is a three step wizard parts 1 & 2 I thiink you have accomplished.

Don't forget to tick the view on open tickbox on the menu (bottom left)

David
 

Attachments

Hi wow, rapid response.

The Embedded objects solution looks good and is something that I can find a use for, thank you. It does not quite solve my existing problem though.

We have a Solidworks CAD system which outputs PDF drawings to a specified Folder, Each drawing has a uniique part number i.e 1234-222-2.PDF

I have an ERP system which we use to raise manufacturing works orders for some of the parts. i.e Manufacturing order W12345 for part 1234-222-2

I am using access to select ranges of Manufacturing orders (from the ERP system via ODBC) with a specific due date, lets say W12345 is one of them. I was intending to use Access to print the works order using a loop so the first Works order number is displayed in one field, the part number in another field temporailly whilst it prints, it then loops back to the next WO number etc

I wanted to build in a step that uses the part number field (whilst it is temporaily displayed)in field Text18
i.e
Dim STRFILE As String
STRFILE = [Forms]![form2]![Text18]

Application.FollowHyperlink STRFILE

where STRFILE could be
\\svr1\Data\3576-246-2.pdf


I was then hoping to set Acrobat up so that it would open in print mode, print the drawing and close itself before looping to the next WO number / Part Number.

Does this all make sense and/or am I asking for the impossible?

Regards
Kevin
PS my VB skills are currently quite limited
 
Don't know if its correct but I cannot logically see how you could control and outside entity (Acrobat) from within Access. As per telling it to Open >Print >close ; Open > Print > Close; etc.

You can initiate the first open but at that point Acrobat has the focus and as such something has to instruct it to print then close. The only way might be through DDE Dynamic Data Exchange. Other than that if Acrobat has some sort of SDK to pass arguments in the command lines then I think it's a problem.

David
 

Users who are viewing this thread

Back
Top Bottom