Question

Locked

Access and PDF

By dbruce ·
I?m trying to use MS Access and VBA to open a PDF file in Reader and go to a specific page. I?m using OLE Automation to try to use the AcroPDF.dll library and it?s methods, such as ?LoadFile? and ?SetCurrentPage? which should do what I want. But I can?t seem to get the code right to reference the AcroPDF library and get its methods to work. I?ve gone to Tools|References and set up a reference to Adobe Reader 7.0 which refers to that library, but the methods still don?t work.

Does anyone know how to use VBA to establish the reference and correctly use methods?

Thanks.

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Use a shell

by bschaettle In reply to Access and PDF

Acrobat command line parameters are documented here:

http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf

To open the PDF file, use a shell, as shown here.

Sub Open_PDF_To_Page()
Dim RetVal
Dim cmd As String
Dim Fullpath As String
Dim PageNum As Integer
Fullpath = "C...\SomeFile.pdf"
PageNum = 3
cmd = Chr(34) & "C:\Program Files\Adobe\Acrobat 7.0\reader\AcroRd32.exe" & Chr(34) & _
" /a " & _
Chr(34) & "page=" & PageNum & Chr(34) & " " & _
Chr(34) & Fullpath & Chr(34)
RetVal = Shell(cmd, 1)
End Sub

Collapse -

Locate and Open Current Version of Acrobat

by erodriguez In reply to Use a shell

I like your code and I am attempting something similar in AccessVB.

I can open a specific PDF located in a directory on the server using this piece of code:

Private Sub HLINK_Click()
Dim pdffile As String
pdffile = HLINK 'This field contains the text string with the full file path to the pdf'
Shell "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe " & pdffile
End Sub

My problem is what if the user has Acrobat 5.0 or 7.0? How can make it so that it launches the currently installed version of Acrobat?

Collapse -

Locate and Open Current Version of Acrobat

by erodriguez In reply to Use a shell

I like your code and I am attempting something similar in AccessVB.

I can open a specific PDF located in a directory on the server using this piece of code:

Private Sub HLINK_Click()
Dim pdffile As String
pdffile = HLINK 'This field contains the text string with the full file path to the pdf'
Shell "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe " & pdffile
End Sub

My problem is what if the user has Acrobat 5.0 or 7.0? How can make it so that it launches the currently installed version of Acrobat?

Collapse -

Path to associated program is in the registry

by bschaettle In reply to Locate and Open Current V ...

I have some VBScript code that should help. I'm not at the office until next week; I'll post it then.

Collapse -

VBScript Code

by erodriguez In reply to Path to associated progra ...

Thanks, That would be great.

Collapse -

path is in registry

by erodriguez In reply to VBScript Code

Took your reply and did search on it and came across the below code:

GetApplicationPath - Retrieve the path of a Windows application from the Registry
Const HKEY_LOCAL_MACHINE = &H80000002

' Get the path of a Windows application
' or an empty string if the application isn't registered
'
' this routine only works for those applications that register
' themselves under the registry key
' HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths
'
' You can use it to retrieve the path of all MSOffice apps,
' MS Access, SQl Server, Windows Dialer, and more, for example
' ' Run Excel in a maximized window
' Shell GetApplicationPath("EXCEL.EXE"), vbMaximizedFocus
'
' requires the GetRegistryValue function

Function GetApplicationPath(ByVal ExeName As String) As String
GetApplicationPath = GetRegistryValue(HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion\App Paths\" & ExeName, "")
End Function


It does not work because when I compile the function, i get an error that the function is not defined.

Collapse -

Access and PDF

by post In reply to Path to associated progra ...

This is my code for opening av PDF-file from an Access (2003) Form:

Dim PDFVedlegg As String
PDFVedlegg = G_VedleggKatalog & S?knads?r & "\" & VedleggFilPDF

Application.FollowHyperlink PDFVedlegg, , True

Back to Software Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums