How to open a pdf file

P

PayeDoc

Hello All

I have a button on a form that I want to use to open a particular pdf file.
I had tried doing this with a macro, using the RunApp command, but can't get
it to work (see my post in the macros newsgroup), and in any case I wondered
whether this would be best done with code - but I don't know the syntax!

The file I want to open is called
GP reg Pay Circular 2009-10.pdf

and it is on the root directory of our fileserver, which is mapped as the Z
drive on the various workstations.

How do I open this file using code? Presumably I need first to specify the
path to open Adobe Reader: this is
C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe

For what it's worth, the argument for the RunApp command was
="C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" & """" & " " & """"
& "Z:\GP reg Pay Circular 2009-10.pdf" & """"

.... but I kept getting a message that the file cannot be found. I tried
various amendments of the apostrophes, but to no avail!

Am I right to suppose that this would be easier using code, rather than the
macro RunApp command?

Hope someone can help.

Many thanks
Leslie Isaacs
 
K

Krzysztof Naworyta

PayeDoc wrote:

| I have a button on a form that I want to use to open a particular pdf
| file. I had tried doing this with a macro, using the RunApp command,
| but can't get it to work (see my post in the macros newsgroup), and
| in any case I wondered whether this would be best done with code -
| but I don't know the syntax!
|
| The file I want to open is called
| GP reg Pay Circular 2009-10.pdf
|
| and it is on the root directory of our fileserver, which is mapped as
| the Z drive on the various workstations.
|
| How do I open this file using code? Presumably I need first to
| specify the path to open Adobe Reader: this is
| C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe
|
| For what it's worth, the argument for the RunApp command was
| ="C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" & """" & " "
| & """" & "Z:\GP reg Pay Circular 2009-10.pdf" & """"
|
| ... but I kept getting a message that the file cannot be found. I
| tried various amendments of the apostrophes, but to no avail!
|
| Am I right to suppose that this would be easier using code, rather
| than the macro RunApp command?


Yes, much easier...

Private Sub Command1_Click()
Application.FollowHyperlink "Z:\GP reg Pay Circular 2009-10.pdf"
End Sub
 
P

PayeDoc

Hello Krzysztof

Many thanks for your reply.

I tried
Application.FollowHyperlink "Z:\GP reg Pay Circular 2009-10.pdf"
.... but nothing happened!
Is there something else I need to do?

Thanks for your continued help.
Les
 
P

PayeDoc

Hello Arvin

Many thanks for your reply.

I pasted all the code at http://www.mvps.org/access/api/api0018.htm into a
new module, then set the OnClick event of the button to
fHandleFile (Z:\GP reg Pay Circular 2009-10.pdf)
but this showed a (compile?) error on the colon after the Z, so I tried
fHandleFile ("Z:\GP reg Pay Circular 2009-10.pdf")
.... but then I get an 'Argument not optional' error!

What have I done wrong?
Hope you can help.
Les
 
K

Krzysztof Naworyta

Juzer PayeDoc <[email protected]> napisa³
| Hello Krzysztof
|
| Many thanks for your reply.
|
| I tried
| Application.FollowHyperlink "Z:\GP reg Pay Circular 2009-10.pdf"
| ... but nothing happened!
| Is there something else I need to do?

Where did you put that text?

Have you any application registered to open pdfs?
 
L

Leslie Isaacs

Hello Krzysztof

I put that text as the OnClick event of a button.
If I click on any pdf file from Windows exporer, it opens fine with Adobe
Acrobat Reader, and I assumed this means that Adobe Acrobat Reader is
registered to open pdfs. Is that not necessarily true?

Thanks again for the help.
Les
 
K

Krzysztof Naworyta

Juzer Leslie Isaacs <[email protected]> napisa³

| I put that text as the OnClick event of a button.

If you call properties window of your button you have some options:
- expression (e.g.: =FunctionName())
- macro name
- event procedure

You have to choose the third option, that opens module window (VBE) where
you can type my line in procedure body.
 
L

Leslie Isaacs

Hello Krzysztof

That's exactly what I did!
From the Properties window I selected the Event properties, then selected
the OnClick event, then clicked the 3 little dots and selected the Code
Builder to open the event procedure, then pasted in your line into the
module. Perhaps it should be some other poperty?
Sorry for my ignorance!

Hope you can still help.

Thanks again
Les
 
P

PayeDoc

Hello Arvin

Thanks for the further reply.
With the addition of the Win_NORMAL argument, I now get a compile error:
Expected: =
.... and the cursor flashes at the end of the line.

Should I be assigning the fHandleFile expression to some variable in order
to open the file?

Sorry about my ignorance - and hope you can help!

Thanks again
Les
 
P

PayeDoc

Arvin

No: I named the module "Arvin Meyer"!!

What else could the problem be?

Many thanks for your further help.
Les
 
D

Douglas J. Steele

fHandleFile is a function.

You either need to assign its return value to a variable

SomeVar = fHandleFile("Z:\GP reg Pay Circular 2009-10.pdf", Win_NORMAL)

or prefix the invocation with Call

Call fHandleFile("Z:\GP reg Pay Circular 2009-10.pdf", Win_NORMAL)

or leave off the parentheses

fHandleFile "Z:\GP reg Pay Circular 2009-10.pdf", Win_NORMAL

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)
 
P

PayeDoc

Douglas

Alleluia!!

This has been a very long haul - for what I had assumed would be a simple
problem. Many thanks for not your perseverance!

Les
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top