Can a macro open a pdf file ?

  • Thread starter Thread starter Roger Ottaway
  • Start date Start date
R

Roger Ottaway

I have about 400 model forms, each one from one of about 200 countries, and
in dutch or french. I have a table with the country name, language of the
form, and file path for the form.pdf file. I can set up a query to filter
out the country/language/form I want, and its file location on my c:\ drive,
but how can I set up a macro to then go from access to open the pdf file ?

thanks

Roger
 
Roger,

I think you will be able to do this with a RunApp macro, and use an
expression in the Command Line argument to return the path and file name
of your pdf file.
 
Thanks for your help, but it doesn't seem to work. I have created a field in
my query named FilePath, which returns the path to the pdf file for the
country I want (for example C:\office\models\fijiNL.pdf). I have also
created a macro, with just one line RunApp with the Command line being
FilePath. But when I run the macro I get the error message that it can't
invoke the application because the path to the application is invalid (which
it is not), or a component of the application is missing. Any ideas ?



thanks



Roger
 
Roger

The way you are doing it, Access has no way of knowing what "FilePath"
means, or what it refers to. Try it like this...
=DLookup("[FilePath]","NameOfYourQuery")
Alternatively, you could have a form which will be open at the time you
run the macro, with a textbox bound to the FilePath field, and then in
the Command Line argument of the macro you would put the equivalent of...
=[Forms]![NameOfYourForm]![FilePath]
 
Dear Steve

thanks for your help, sorry I'm a bit slow ... I have created a form called FormCountry based on the query with a text box bound to the FilePath field. I have a command button in the form which runs the macro. In the macro I still have the one line RunApp and in the command line put =[Forms]![FormCountry]![FilePath] ... but I get the same error message. I have used DLookup in Excel, but where do I put it to use it in Access ... in the macro ? or somewhere in the properties of the FilePath text box in the form ? I am using Access2002 on XP, does that make a difference.

thanks

Roger
 
Roger,

Did you remember to include the path to the application you want to run
with the RunApp, as well as the path to the document. The text in your
[FilePath] field should look something like this...
"C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe"
"C:\office\models\fijiNL.pdf"
Alternatively, the problem might be with the use of FilePath. If this
is the name of the field in the query, and not the name of the textbox
on the form, try it with the actual name of the textbox.
 
Dear Steve

thanks for your help so far, should I have opening adobe and opening my fiji.pdf file as two separate RunApp lines in the macro ? When I have two lines adobe reader opens just fine, but I still get that error message for the fiji.pdf file. The text box name is what I am using. Can I open two files with the same RunApp command line (can I put them in the same line and separate them with a semi-colon or something?) should I have the "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" and "C:\office\models\fijiNL.pdf" in quotes ? How does adobe know to open the second (fiji.pdf) file ?

thanks

Roger
 
Dear Steve

an update on my previous email. When I put "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" and "C:\office\models\fijiNL.pdf", in quotes with a single space separating them in the control line of a single RunApp in a macro, it works just fine. Including when the macro is embodied in a form.

But when I try running the macro (from within the form) with the text box reference in the control line, I get the error message. In the arguments part of the error message (telling me that the Action Failed) it has the adobe path and the C\office\models\fiji.pdf path correct, and I have them both in quotes with a space separating them, but I still get that pesky error message !

If I have two RunApp lines, the adobe opens just fine, but I still get the error for the fiji.pdf line. I just can't understand it "

Roger
 
Hi Roger,

I am sorry, I don't know what is going on here either. This is normally
straightforward. I have reproduced your scenario here, and it works
fine for me. You should have this entered in your textbox...
"C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe"
"C:\office\models\fijiNL.pdf"
.... and you should have this entered for the Command Line argument in
the macro...
=[Forms]![NameOfForm]![NameOfTextbox]
Which event on the form are you triggering the macro from?
 
Dear Steve

I don't know how to say this, but first I apologise ... I have again triple checked everything and what had happened is that I had the name of the adobe reader (AcroRd32.exe) in my table with an incorrect spelling (I left off the 2 in 32). Once I fixed that it all worked okay.

I guess the moral of the story is to always make really sure that all the detail in the table is correct !

thanks for your help, it has been a good learning experience for me and I appreciate your help

Roger
 
Thanks for letting me know, Roger, and pleased to know it is working for
you now. Yes, that's the trouble with darn computers... they're so
fussy about the little things.
 
Back
Top