Opening JPG files via "followhyperlink", or other code...

  • Thread starter hubbiida via AccessMonster.com
  • Start date
H

hubbiida via AccessMonster.com

I have read repeatedly on this forum about using "Application.
Followhyperlink" to launch files in their default applications. I am trying
to use this techique to open .jpg files, using a control from a form to
provide the file path. The problem is that the .jpg files open in Internet
Explorer. I have associated .jpg with a graphics program (Fireworks) and when
a file is double clicked in Windows Explorer it opens in that application,
but I cannot get them to open in Fireworks from Access using Application.
Followhyperlink...

I have also tried the following code (which I found on anther post):

Dim app_name As String

app_name = "C:\Program Files\Macromedia\Fireworks MX 2004\Fireworks.exe
<path_to_file>"

Call Shell(app_name, 1)

This works great when I put in a literal path to the file, but when I simply
name the control (which contains the path) I get different errors depending
on the syntax I use.

Any suggestions for the proper syntax to use a control as <path_to_file>
above, or on why the .JPG files always open in IE would be most welcome.
 
D

Douglas J. Steele

Assuming that the control which contains the file name is txtFile, try
something like:

Dim app_name As String

app_name = Chr$(34) & "C:\Program Files\Macromedia\Fireworks MX
2004\Fireworks.exe" & _
Chr$(34) & " " & Chr$(34) & Me.txtFile & Chr$(34)

Call Shell(app_name, 1)


The quotes (Chr$(34)) should handle any problems with embedded blanks in the
file name.
 
H

hubbiida via AccessMonster.com

Douglas, thank you so much. I was really pulling my hair out over this one,
because I knew that the FollowHyperlink method should have worked, but
apparently Access simply can't open certain applications that way. Anyhow,
here is the code, (a slight variation of whay you provided) that did the
trick:

Dim app_name As String

app_name = "C:\Program Files\Macromedia\Fireworks MX 2004\Fireworks.exe" & "
" & Chr$(34) & Me.control_name & Chr$(34)

Call Shell(app_name, 1)

Thanks again,
Andrew
Assuming that the control which contains the file name is txtFile, try
something like:

Dim app_name As String

app_name = Chr$(34) & "C:\Program Files\Macromedia\Fireworks MX
2004\Fireworks.exe" & _
Chr$(34) & " " & Chr$(34) & Me.txtFile & Chr$(34)

Call Shell(app_name, 1)

The quotes (Chr$(34)) should handle any problems with embedded blanks in the
file name.
I have read repeatedly on this forum about using "Application.
Followhyperlink" to launch files in their default applications. I am
[quoted text clipped - 24 lines]
Any suggestions for the proper syntax to use a control as <path_to_file>
above, or on why the .JPG files always open in IE would be most welcome.
 

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