Solved

VBA Hyperlink won't open jpg files properly

Posted on 2012-03-12
7
646 Views
Last Modified: 2012-03-15
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
Comment
Question by:isurgyn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37711715
I would suspect it's because 'hyperlinks' open in IE.  See if your code works on local JPGs without a hyperlink.
0
 

Author Comment

by:isurgyn
ID: 37712037
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
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 250 total points
ID: 37712333
"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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 65

Expert Comment

by:rockiroads
ID: 37713285
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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37714546
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
 

Author Comment

by:isurgyn
ID: 37715623
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
 

Author Closing Comment

by:isurgyn
ID: 37727165
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question