I want to open a local file using a hyperlink in access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In my database I have a field where I list a filepath to an Adobe Photoshop
..psd file. I have set this field's property to IsHyperlink and it appears to
work except that as soon as the file is opened in Photoshop, Photoshop
immediately closes. I tried an experiment where I changed the data to some
other type (I used a .doc file) and this worked as it should. Does anyone
have any idea why this is happening and is there a work-around?

Much appreciated!!
 
Adobe files do seem to be a little temperamental as far as hyperlinks are
concerned. A while ago someone had problems opening .pdf files, though in
their case Acrobat Reader stayed open but the .pdf file closed. I was able
to reproduce the behaviour at the time, but subsequently had no problem with
it! I've found the most reliable way to open a file associated with an
application is by means of the Windows API ShellExecute function. Put the
following module in the database:

Option Compare Database
Option Explicit

Declare Function ShellExecute& Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal _
hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, ByVal nshowcm As Long)

Sub ShellToFile(strPath As String, ByVal lngHwnd As Long)

Dim lngRetVal As Long

lngRetVal = ShellExecute(lngHwnd, "open", strPath, _
vbNullString, CurDir, 1)

If lngRetVal < 32 Then
MsgBox "Unable to open file " & strPath, vbInformation, "Warning"
End If

End Sub

The paths to the files can be stored in a text field, txtFilePath say, and
opened from a bound form with:

ShellToFile Me.txtFilePath, hwnd

Ken Sheridan
Stafford, England
 

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

Back
Top