Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to Open a PDF File with Hyperlink Property

Status
Not open for further replies.

nobull613

Technical User
Jun 6, 2003
76
US
I'm trying to use a button to open a User's Guide for the database (Access 2002), using the Hyperlink property of the button. The guide is in the same folder on the network as the database.

When I click the button on my PCs the pdf opens fine. When a user clicks it, Adobe opens but then immediately closes.

Is there a setting that would cause this? Would some code be better to use than the Hyperlink Property?

Thanks!
 
Hi,

Im not sure about the settings part, but I have a button on one of my forms that opens up a word document, and it also opens a pdf file as just tested with a pdf file on my pc. Here is the code:

Code:
Private Sub cmbOpenFile_Click()

    RunProgram "Enter path name here e.g. C:\Documents and Settings\Word document.doc"

End Sub

Hope this helps,

Andrew
 
Code:
Public Function OpenDocument(DocumentWithPath As String) As Long
    OpenDocument = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocumentWithPath, vbNormalFocus)
End Function

[Code In Your Button Click Event]
Dim a As Long
DoCmd.Hourglass True
If Dir(Server_Location & SupportPath & TheHelpFile) <> "" Then
a = OpenDocument(Server_Location & SupportPath & TheHelpFile)
DoCmd.Hourglass False
Else
DoCmd.Hourglass False
MsgBox "Help file not found.", vbCritical, App_Name
End If
[/code]
 
Hi nobull613,

Apologies, if you are using the code I put up, you will also need this in a Module:

Code:
Public Sub RunProgram(strProgram As String)

Dim lRet As Long

    ' Execute the API call
    lRet = ShellExecute(0&, vbNullString, strProgram, vbNullString, vbNullString, vbNormalFocus)
    
    'If ShellExecute works it will return a number greater than 32
    If lRet <= 32 Then
        MsgBox "Error Running Program"
    End If
    
End Sub

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top