Link to home
Start Free TrialLog in
Avatar of isurgyn
isurgyn

asked on

VBA Hyperlink won't open jpg files properly

Hi,

I have been using the following hyperlink code in my Access database.  It works great for pdf files but when I try to hyperlink to a jpg format it attempts to open the file in Internet Explorer.  

I have set the typical application for these files as Windows Picture and Fax Viewer and the files open properly when opened directly.  Any thoughts?

    Dim FilePath As String
    Dim strAdobe As String
   
    On Error GoTo ErrHandler
   
    FilePath = DLookup("[PatientFolderPath]", "tblPathNames", 1)
    FilePath = FilePath & Me.PatientID.Value

    If Right(FilePath, 1) <> "\" Then
        FilePath = FilePath & "\"
    End If
   
    FilePath = FilePath & Me.WaveScanFileName
   
    Me.LabelH.HyperlinkAddress = FilePath
    Me.LabelH.Hyperlink.Follow
   
    Exit Sub
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

I would suspect it's because 'hyperlinks' open in IE.  See if your code works on local JPGs without a hyperlink.
Avatar of isurgyn
isurgyn

ASKER

I am suspecting it is a problem with registering the default application that is to open jpg files.  The system I am having problem runs XP.  

I did a test on a Windows 7 computer after my post and the code works perfectly as is so it appears to be a problem either with that system or a difference in how XP selects the default application for a hyperlink.

I had already opened a jpg file directly and set the default application for that file type on the XP machine but perhaps I am not doing that correctly.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Maybe cos its a hyperlink it uses a browser to open.
You can use the shellexecute api to open jpgs in the app that is associated to it (file/picture browser). Make your control look like a hyperlink, on click event will run the api call.

Or maybe try prefixing your path with file:// and see what happens
rocki,

Great to hear from you again...
;-)

<Maybe cos its a hyperlink it uses a browser to open.>
My computer opens hyperlinks in whatever the default app is...

I think IE is the default.
That is why I am wondering if the OP checked the Folder Options, (or perhaps just reset them), it might clear things up...???

Jeff
Avatar of isurgyn

ASKER

Thanks for the help.  I am out of the office until tomorrow and will check the suggestions out then.  I did NOT open the tools and set the default app for jpg file types so that is undoubtedly the problem.  What I did was right click on the specific jpg file target and opened properties.  Under 'General' there is the option to 'Open With' I selected 'Change' and set the default to Windows Picture and Fax Viewer.  Perhaps that only sets that for that one file rather than all jpg files.

I could use the shell option but the types of files that the command is designed to open is currently a mix of jpg and pdf's.  In that setting a hyperlink is likely the best option to use.

I will get back to you tomorrow on the solution since it is not really an Access vba issue but rather looks to be stemming from my lack of familiarity with setting default applications in Windows XP.
Avatar of isurgyn

ASKER

Ok I checked the default application.  The jpg extention was ok but the jpeg extention was not.  So set the default application for both file types and the hyperlink is working fine.

Thanks.