5
Contributors
6
Replies
8
Views
9 Years
Discussion Span
Last Post by goldriverdancer
0

You don't say whether you want to call it from a menu or a button or something else, but whatever the mode, you'll want to do if from a macro attached to that mode.

In your form, create a button (for example) and for the OnClick property, call the macro macOpenPDF (for example). In the Action column, use "runapp" and for the command line argument, you must reference the path and filename to Adobe Acrobat (the application) and then, the path to the actual document you want to open. In my test form, here is my command line argument for the runapp action:

C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe c:\clc-drive.pdf

Save the macro and the form, then click that sucker and see it work! Of course, you can use this same method to open any document from any valid application, even text files in Notepad. But make sure your users will have the same applications at the same path destinations or the logic will fail.

Good luck- SLH

0

this macro works fine..
but in my access 2003 application, i am able to save the reports in pdf format and then save them to c:\pdfreports\ *.pdf

i have up to 10 reports saved as pdf's in the directory.
what i want todo is to have the user open a combo box which contains the 10 reports in the above dir. when the click on the desired report i want the pdf to open with the selected one being opened..

as you know, the macro is not able to be changed to open the selected report.

there has got to be some code to allow me to input thcorrect selected pdf report into the command to be opened in the AcroRd32.exe can' use RUNAPP cause it's for macro's.
what can i do ??

thanks
joe archer sr san diego

0

The problem i was having was getting quotes around the path to the reader and also quotes around the path to the PDF. See below for my solution. It should be dead easy to incorporate this code into your project. Hope this helps someone! Soporific.

Private Sub Go_PDF_v2(myPath As String)
' this routine uses the FileExists function from [url]http://allenbrowne.com/func-11.html[/url]
' tested working on MS Access 2003
' the sub routine accepts the path of a PDF file as the myPath variable

Dim ReaderPath, RetVal

ReaderPath = "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"
If Not FileExists(ReaderPath) Then ReaderPath = "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe"
If Not FileExists(ReaderPath) Then ReaderPath = "C:\Program Files\Adobe\Reader 7.0\Reader\AcroRd32.exe"
If Not FileExists(ReaderPath) Then
    MsgBox "I can't find the Acrobat reader"
    Exit Sub
End If

If FileExists(myPath) Then
    RetVal = Shell("""" & ReaderPath & """" & " """ & myPath & """", vbNormalFocus)
Else
    MsgBox "Can't find PDF"
End If

End Sub
0

I did it a different way with the same results..
*************
created a command button on form with the following code.
***********

Private Sub Combo756_Click()

    Dim stDocName As String
    Dim MyRPT As String
    MyRPT = Combo756
    stDocName = """" & MyRPT & """"
    Dim PDFFILE As String
    PDFFILE = Combo756    'This field contains the text string with the full file path to the pdf'
    PDFFILE = """" & PDFFILE & """"
    Shell "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe " & PDFFILE
    MyRPT = Combo756
    stDocName = """" & MyRPT & """"
    PDFFILE = Combo756    'This field contains the text string with the full file path to the pdf'
    PDFFILE = """" & PDFFILE & """"
    Shell "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe " & PDFFILE
End Sub

*****************
thanks
joe archer san diego

0

Hey all,

Thanks for the code. I tried it on a command button and it works fine. However, I was wondering about joe archer's earlier question: how to get a combo box on a form to display a drop down list of say 5 pdf files, and if the user clicks on one of them, the specific file will show up? Also, if I have 5 different pdf files i want to call up for each entry in the table, how do i do that?

I know how to embed pdfs as OLE objects, but I read that this will take up a lot of space in the database.

Any help will be much appreciated.


Big Access Noob

0

Oops, actually that IS the code! Sorry about that. Tried it again and it worked like a charm. Thanks!

Just need a little bit more guidance though. How to call up different pdfs for each entry in the table?

Thanks so much for your help...


Noobie

Hey all,

Thanks for the code. I tried it on a command button and it works fine. However, I was wondering about joe archer's earlier question: how to get a combo box on a form to display a drop down list of say 5 pdf files, and if the user clicks on one of them, the specific file will show up? Also, if I have 5 different pdf files i want to call up for each entry in the table, how do i do that?

I know how to embed pdfs as OLE objects, but I read that this will take up a lot of space in the database.

Any help will be much appreciated.


Big Access Noob

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.