Application.FollowHyperlink doesnt work (1 Viewer)

widemonk

Registered User.
Local time
Today, 05:32
Joined
Jun 16, 2005
Messages
48
Can anyone please help with the following.

If the file its trying to refer to does not exist, sure enough I get a 'Cannot find file' message box.
If the file does exists, the program begins to load Adobe but half a second later, closes again.

Its OK with XP running Office 2007 and Adobe Reader but fails with (dare I say it) Vista, Access2000 and Adobe Professional.

Code:
Private Sub lblShowQuote_Click()

Dim QuoteNo As String

QuoteNo = "G:\Quotes\" & txtQuoteID & ".pdf"

On Error GoTo Err_CannotOpenEnquiry

Application.FollowHyperlink QuoteNo

Exit_Err_CannotOpenEnquiry:
    Exit Sub

Err_CannotOpenEnquiry:
    MsgBox Err.Description
    Resume Exit_Err_CannotOpenEnquiry

End Sub

Im trying to avoid Shell to an absolute Adobe file name in case anyone has a different version and therefore different path/filename for the Adobe application. I just want it to open in the default application that would normally open a .pdf

... anyone ???

Thanks :)
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:32
Joined
Jan 23, 2006
Messages
15,394
It may be that FollowHyperlink was added to Access in 2003 version.
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:32
Joined
Jan 23, 2006
Messages
15,394
Where and how is txtQuoteId defined?
 

widemonk

Registered User.
Local time
Today, 05:32
Joined
Jun 16, 2005
Messages
48
txtQuoteID is the form Text Box thats bound to the autonumber field that generates the quote number itself.
 

DCrake

Remembered
Local time
Today, 05:32
Joined
Jun 8, 2005
Messages
8,632
Place the following into a standard module

Code:
Public Declare Function ShellExecute Lib "shell32.dll" _
   Alias "ShellExecuteA" _
   (ByVal hWnd As Long, ByVal lpszOp As String, _
    ByVal lpszFile As String, ByVal lpszParams As String, _
    ByVal LpszDir As String, ByVal FsShowCmd As Long) _
    As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Const SW_SHOWNORMAL = 1


Then in your form place the following code on the double click event of the control

Code:
    nDT = GetDesktopWindow()
    nApp = ShellExecute(nDT, "Open", StrDefaultPathAndFileName, "", "C:\", SW_SHOWNORMAL)

Where StrDefaultPathAndFileName is the full path and file name that you want to open.

This works for any type of file and opens the nominated file in its native software.
 

Users who are viewing this thread

Top Bottom