Solved

VBA Hyperlink won't open jpg files properly

Posted on 2012-03-12
7
641 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
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

837 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