• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 702
  • Last Modified:

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
0
isurgyn
Asked:
isurgyn
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
I would suspect it's because 'hyperlinks' open in IE.  See if your code works on local JPGs without a hyperlink.
0
 
isurgynAuthor Commented:
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.
0
 
Jeffrey CoachmanCommented:
"but perhaps I am not doing that correctly."
...?
You never stated how you are doing this...?

This should be easy to set in the "Folder Options"

Open any folder
Tools-->Folder Options
click the File Types tab.

Just note that there are some image application out there that will change this setting without you knowing...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
rockiroadsCommented:
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
0
 
Jeffrey CoachmanCommented:
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
0
 
isurgynAuthor Commented:
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.
0
 
isurgynAuthor Commented:
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now