Solved

VBA Hyperlink won't open jpg files properly

Posted on 2012-03-12
7
601 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 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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
Comment Utility
"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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now