Open a PDF file

G

Guest

Hi,

Can anyone please tell me how to modify the code below so it opens an Adobe
(PDF) file instead of a Word file.

Sub OpenWordDoc(strDocName As String)
Dim objApp As Object

'Opens the document

Set objApp = CreateObject("Word.Application")
objApp.Visible = True
objApp.Documents.Open strDocName
End Sub

What I like is from my Microsoft Access form, to hyperlink to an Adobe PDF
document. At present each record contains a document name and a full file
path to where the document is stored. I would like to open Adobe and view the
specified PDF document. Thank you.
 
D

Dirk Goldgar

In
Milazimi said:
Hi,

Can anyone please tell me how to modify the code below so it opens an
Adobe (PDF) file instead of a Word file.

Sub OpenWordDoc(strDocName As String)
Dim objApp As Object

'Opens the document

Set objApp = CreateObject("Word.Application")
objApp.Visible = True
objApp.Documents.Open strDocName
End Sub

What I like is from my Microsoft Access form, to hyperlink to an
Adobe PDF document. At present each record contains a document name
and a full file path to where the document is stored. I would like to
open Adobe and view the specified PDF document. Thank you.

You ought to be able to just tell Access to follow the file path as a
hyperlink; e.g.,

Application.FollowHyperlink Me!txtFullPathToPDFFile
 
G

Guest

Dirk Goldgar said:
In

You ought to be able to just tell Access to follow the file path as a
hyperlink; e.g.,

Application.FollowHyperlink Me!txtFullPathToPDFFile

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


I’m using module that calls directly into comdlg32.dll to allow user to select a filename using the Windows Common Dialog. Therefore the path will be selected from the user. After path is selected there is a cmdbutton that calls the procedure above to open a Word file. This works well for word, but when I try to open a PDF document, it opens in Word with funny characters on it.
 
G

Guest

Milazim,

If you intend to open a report in PDF, then you might want to take a look at
Leban’s page: http://www.lebans.com/reporttopdf.htm

But if you want to open a specified PDF file located on C: or shared/server
drive, then try this:

Private Sub RunAdobe_Click()
On Error GoTo Err_rnn_Click

Dim stAppName As String

stAppName = "C:\Program Files\Adobe\Designer 7.0\FormDesigner.exe"
Call Shell(stAppName, 1)

Exit_rnn_Click:
Exit Sub

Err_rnn_Click:
MsgBox Err.Description
Resume Exit_rnn_Click

End Sub


Have a nice one!
Adnan
 
D

Dirk Goldgar

In
Sure, if you use the code you posted, but with strDocName pointing to a
PDF file, it'll try to open it in Word (because that's what you're
telling it to do), and it won't come out right. But if you just use the
code I posted to open your strDocName, like this:

Application.FollowHyperlink strDocName

That should open it with whatever application is registered to handle
the file. If it's a PDF file, it should open it with Adobe. If it's a
Word document, it should open it with Word.
 

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