FollowHyperlink JPG Opens In Internet Explorer

K

Keith

I am using the FollowHyperlink method to open jpg files. On my development
system (Vista Business, Office 2007), this opens the file using the default
application for jpegs, Microsoft Office Picture Manager, as expected.

One of my users is running XP Pro, and has only the Access 2007 runtime
installed. Although Windows Picture and Fax Viewer is the default
application to open JPG files on this machine, this code opens the JPG in
Internet Explorer instead. This is a problem in that IE 8 is unable to print
the JPG properly.

Is there any reason why the FollowHyperlink method would behave differently
in Access 2007 runtime? Is there a fix/workaround?

Thanks,

Keith
 
T

Tom van Stiphout

On Thu, 30 Jul 2009 06:36:06 -0700, Keith

I have never heard of this problem, but a possible workaround would be
to use the ShellExecute API with the OPEN verb.

-Tom.
Microsoft Access MVP
 
K

Keith

Tom,

Thanks for the response. I have confirmed the same behavior on another
machine running Access Runtime. I have also seen the behavior on a machine
running Office 2000.

The suggestion to use ShellExecute is a good one. The problem, though, is
that I need be sure that the user has the specified program installed (and
that it is installed in the exact same location). That's why I liked the
idea of using FollowHyperlink.

Thanks,

Keith
 
D

David H

What about using automation to instantiate an instance of the application
explicitly and then open the file within it? I've done that several times
with Word without any problems.

Dim appWord As Object
Dim varTemplate

Set appWord = CreateObject("Word.Application")
appWord.Visible = True

varTemplate = DLookup("txtNameSignTemplate", "tblMasterAccounts",
"[lngMasterAccountId] = [Forms]![frmReservations]![cboMasterAccount]")

If IsNull(varTemplate) Then
varTemplate = "Standard Name Sign.doc"
End If

varFullFileName = "C:\Documents and Settings\dch3\My documents\willard
madison\name signs\" & varTemplate
appWord.Documents.Open FileName:=varFullFileName
appWord.Documents(varTemplate).FormFields("nameSign").Result =
[Forms]![frmReservations]![txtNameSign]

Set appWord = Nothing
 
S

Stuart McCall

Keith said:
I am using the FollowHyperlink method to open jpg files. On my development
system (Vista Business, Office 2007), this opens the file using the
default
application for jpegs, Microsoft Office Picture Manager, as expected.

One of my users is running XP Pro, and has only the Access 2007 runtime
installed. Although Windows Picture and Fax Viewer is the default
application to open JPG files on this machine, this code opens the JPG in
Internet Explorer instead. This is a problem in that IE 8 is unable to
print
the JPG properly.

Is there any reason why the FollowHyperlink method would behave
differently
in Access 2007 runtime? Is there a fix/workaround?

Thanks,

Keith

Try this: open windows explorer and navigate to your jpg folder. Highlight
any jpg file and right-click. Choose 'Open With...' from the menu. In the
dialog that appears, select 'Windows Picture and Fax Viewer'. Check the
'Always use...' checkbox. FollowHyperlink should now open jpg files using
the fax viewer app.
 
D

Dirk Goldgar

Keith said:
The suggestion to use ShellExecute is a good one. The problem, though, is
that I need be sure that the user has the specified program installed (and
that it is installed in the exact same location). That's why I liked the
idea of using FollowHyperlink.


ShellExecute doesn't require a specific program to be installed, since all
you pass it is the name of the file you want to open. It will use the
application that is registered for the file type. There just has to be some
application registered as the default application to open that type of file.

If you haven't already seen it, look at this article from The Access Web:

http://www.mvps.org/access/api/api0018.htm
API: Start an app with ShellExecute
 
K

Keith

Thanks for the response, Stuart. I had already tried that. Although the
Windows Picture and Fax Viewer is set as the default program for jpg's, that
doesn't seem to apply when running Access 2007 runtime (or Access 2000).

Thanks,

Keith
 
K

Keith

Tom,

After reading Dirk's response, I realized that ShellExecute will work as you
suggested. Thanks for your help.

Keith
 
K

Keith

Dirk,

You are correct. Thanks for setting me straight. ShellExecute works
perfectly.

Keith
 
D

David H

So is ShellExecute the better choice because once the command executes Access
doesn't have anything else to deal with?
 
J

Jack Leach

I use ShellExecute extensively... Shell and App.FollowHyperlink have both
given me various problems in the past, but I've never had difficulty with
ShellExecute.

Personally, I attribute this to the API working on a system level whereas
Shell is a vba function and App.FollowHyperlink has given me what I believe
to be security related bugs, but I don't really know enough about it to back
this claim up.

Also, ShellExecute offers more functionality.

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
D

Dirk Goldgar

David H said:
So is ShellExecute the better choice because once the command executes
Access
doesn't have anything else to deal with?


I'm not sure that Access has anything else to deal with, regardless of
whether you use ShellExecute or Application.FollowHyperlink. However, there
seem to be some circumstances, as you've found, when FollowHyperlink does
not open the registered application for a filetype, but uses Internet
Explorer instead. I've never investigated to see whether it just gives IE
precedence whenever IE can handle the filetype, or what.

Also, I think I have sometimes gotten security prompts with FollowHyperlink,
though I can't recall for sure. My habit is to use ShellExecute when I'm
writing a serious application, and FollowHyperlink for quick-and-dirties.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top