application.hyperlink giving 490 error

T

tstew

Hello,

I have a form with a linked picture. I'm trying to make a double click event
to open the picture with Windows Picture and Fax Viewer. JPG's are associated
to open with that program.

The code is:

Private Sub PicPic_DblClick(Cancel As Integer)

Application.FollowHyperlink CurrentProject.Path & "\Pics\" &
[Pic_Location] & ".jpg"

End Sub

I get the following error message...

"Run-time error '490': Cannot open the specified file."

Any ideas why?

Thanks,
Mark
 
J

Jack Leach

Application.Hyperlink defaults to opening a file as if it were clicked
through a webpage (hence the hyperlink). For instance, if I open a jpg with
AppHyperlink it opens in IE instead of my registered program.

Use the builtin Shell() function or even better, the ShellExecute API which
can be found at mvps.org/access, both of these will open the file using the
registered application.

hth
--
Jack Leach
www.tristatemachine.com

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

tstew

Thank You, Jack. I've looked at the ShellExecute API, and that is over my
head.

I'm trying to use the Shell() function with the following code:

Private Sub PicPic_DblClick(Cancel As Integer)

If IsNull(Me.Pic_Location) Or (Me.Pic_Location) = "*No*" Then

Shell (CurrentProject.Path & "\Pics\NoPicYet.jpg")
Else: Shell (CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg")

End If

End Sub

Don't laugh, it didn't work. I get an "error #5 Invalid procedure call or
argument." Any ideas why?

Thanks,
Mark



Jack Leach said:
Application.Hyperlink defaults to opening a file as if it were clicked
through a webpage (hence the hyperlink). For instance, if I open a jpg with
AppHyperlink it opens in IE instead of my registered program.

Use the builtin Shell() function or even better, the ShellExecute API which
can be found at mvps.org/access, both of these will open the file using the
registered application.

hth
--
Jack Leach
www.tristatemachine.com

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



tstew said:
Hello,

I have a form with a linked picture. I'm trying to make a double click event
to open the picture with Windows Picture and Fax Viewer. JPG's are associated
to open with that program.

The code is:

Private Sub PicPic_DblClick(Cancel As Integer)

Application.FollowHyperlink CurrentProject.Path & "\Pics\" &
[Pic_Location] & ".jpg"

End Sub

I get the following error message...

"Run-time error '490': Cannot open the specified file."

Any ideas why?

Thanks,
Mark
 
J

Jack Leach

Shell (CurrentProject.Path & "\Pics\NoPicYet.jpg")
Else: Shell (CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg")

Remove the paretheses on the arguments


Shell CurrentPorject.Path & "\pics\NoPicYet.jpg"
Else: Shell CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg"




The pareths expect the function to return a value, as in:

Dim x as Variant
x = Shell(CurrentProject.Path & "\Pics\NoPicYet.jpg")

so to call a function without returning a value just ditch the parentheses.

I think this should do it

--
Jack Leach
www.tristatemachine.com

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



tstew said:
Thank You, Jack. I've looked at the ShellExecute API, and that is over my
head.

I'm trying to use the Shell() function with the following code:

Private Sub PicPic_DblClick(Cancel As Integer)

If IsNull(Me.Pic_Location) Or (Me.Pic_Location) = "*No*" Then

Shell (CurrentProject.Path & "\Pics\NoPicYet.jpg")
Else: Shell (CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg")

End If

End Sub

Don't laugh, it didn't work. I get an "error #5 Invalid procedure call or
argument." Any ideas why?

Thanks,
Mark



Jack Leach said:
Application.Hyperlink defaults to opening a file as if it were clicked
through a webpage (hence the hyperlink). For instance, if I open a jpg with
AppHyperlink it opens in IE instead of my registered program.

Use the builtin Shell() function or even better, the ShellExecute API which
can be found at mvps.org/access, both of these will open the file using the
registered application.

hth
--
Jack Leach
www.tristatemachine.com

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



tstew said:
Hello,

I have a form with a linked picture. I'm trying to make a double click event
to open the picture with Windows Picture and Fax Viewer. JPG's are associated
to open with that program.

The code is:

Private Sub PicPic_DblClick(Cancel As Integer)

Application.FollowHyperlink CurrentProject.Path & "\Pics\" &
[Pic_Location] & ".jpg"

End Sub

I get the following error message...

"Run-time error '490': Cannot open the specified file."

Any ideas why?

Thanks,
Mark
 
T

tstew

I still get the same error. Grrr! But, as in your sig line, this forms
project has shown me 100's of ways that don't work. If you have any other
ideas, I'd be grateful. I'll also spend some time with the API and see if I
can make any sense of them. But, time for a bit of football, now.

Thanks again.

Jack Leach said:
Shell (CurrentProject.Path & "\Pics\NoPicYet.jpg")
Else: Shell (CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg")

Remove the paretheses on the arguments


Shell CurrentPorject.Path & "\pics\NoPicYet.jpg"
Else: Shell CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg"




The pareths expect the function to return a value, as in:

Dim x as Variant
x = Shell(CurrentProject.Path & "\Pics\NoPicYet.jpg")

so to call a function without returning a value just ditch the parentheses.

I think this should do it

--
Jack Leach
www.tristatemachine.com

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



tstew said:
Thank You, Jack. I've looked at the ShellExecute API, and that is over my
head.

I'm trying to use the Shell() function with the following code:

Private Sub PicPic_DblClick(Cancel As Integer)

If IsNull(Me.Pic_Location) Or (Me.Pic_Location) = "*No*" Then

Shell (CurrentProject.Path & "\Pics\NoPicYet.jpg")
Else: Shell (CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg")

End If

End Sub

Don't laugh, it didn't work. I get an "error #5 Invalid procedure call or
argument." Any ideas why?

Thanks,
Mark



Jack Leach said:
Application.Hyperlink defaults to opening a file as if it were clicked
through a webpage (hence the hyperlink). For instance, if I open a jpg with
AppHyperlink it opens in IE instead of my registered program.

Use the builtin Shell() function or even better, the ShellExecute API which
can be found at mvps.org/access, both of these will open the file using the
registered application.

hth
--
Jack Leach
www.tristatemachine.com

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



:

Hello,

I have a form with a linked picture. I'm trying to make a double click event
to open the picture with Windows Picture and Fax Viewer. JPG's are associated
to open with that program.

The code is:

Private Sub PicPic_DblClick(Cancel As Integer)

Application.FollowHyperlink CurrentProject.Path & "\Pics\" &
[Pic_Location] & ".jpg"

End Sub

I get the following error message...

"Run-time error '490': Cannot open the specified file."

Any ideas why?

Thanks,
Mark
 
T

tstew

Hi Jack,

After plugging away for a while, it dawned on me that I needed to point to a
program in the shell function, not just a file. So I put the path to the
viewer I use and appended the name and that worked. Messy looking code, but
very effective for what I was trying to do.

Thanks for your input,
Mark

Jack Leach said:
Shell (CurrentProject.Path & "\Pics\NoPicYet.jpg")
Else: Shell (CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg")

Remove the paretheses on the arguments


Shell CurrentPorject.Path & "\pics\NoPicYet.jpg"
Else: Shell CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg"




The pareths expect the function to return a value, as in:

Dim x as Variant
x = Shell(CurrentProject.Path & "\Pics\NoPicYet.jpg")

so to call a function without returning a value just ditch the parentheses.

I think this should do it

--
Jack Leach
www.tristatemachine.com

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



tstew said:
Thank You, Jack. I've looked at the ShellExecute API, and that is over my
head.

I'm trying to use the Shell() function with the following code:

Private Sub PicPic_DblClick(Cancel As Integer)

If IsNull(Me.Pic_Location) Or (Me.Pic_Location) = "*No*" Then

Shell (CurrentProject.Path & "\Pics\NoPicYet.jpg")
Else: Shell (CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg")

End If

End Sub

Don't laugh, it didn't work. I get an "error #5 Invalid procedure call or
argument." Any ideas why?

Thanks,
Mark



Jack Leach said:
Application.Hyperlink defaults to opening a file as if it were clicked
through a webpage (hence the hyperlink). For instance, if I open a jpg with
AppHyperlink it opens in IE instead of my registered program.

Use the builtin Shell() function or even better, the ShellExecute API which
can be found at mvps.org/access, both of these will open the file using the
registered application.

hth
--
Jack Leach
www.tristatemachine.com

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



:

Hello,

I have a form with a linked picture. I'm trying to make a double click event
to open the picture with Windows Picture and Fax Viewer. JPG's are associated
to open with that program.

The code is:

Private Sub PicPic_DblClick(Cancel As Integer)

Application.FollowHyperlink CurrentProject.Path & "\Pics\" &
[Pic_Location] & ".jpg"

End Sub

I get the following error message...

"Run-time error '490': Cannot open the specified file."

Any ideas why?

Thanks,
Mark
 
J

Jack Leach

Hmmm.... I use ShellExecute and pass just the filename and it takes care of
the rest, no need to call the program to open it with as well.

Just copy & paste the code from here into a new module:

http://www.mvps.org/access/api/api0018.htm

(a standard module, not a class or form module)

And then from the event you want to call...




fHandleFile CurrentProject.Path & "\Pics\pic.jpg", WIN_NORMAL



that should be all you need.



--
Jack Leach
www.tristatemachine.com

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



tstew said:
Hi Jack,

After plugging away for a while, it dawned on me that I needed to point to a
program in the shell function, not just a file. So I put the path to the
viewer I use and appended the name and that worked. Messy looking code, but
very effective for what I was trying to do.

Thanks for your input,
Mark

Jack Leach said:
Shell (CurrentProject.Path & "\Pics\NoPicYet.jpg")
Else: Shell (CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg")

Remove the paretheses on the arguments


Shell CurrentPorject.Path & "\pics\NoPicYet.jpg"
Else: Shell CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg"




The pareths expect the function to return a value, as in:

Dim x as Variant
x = Shell(CurrentProject.Path & "\Pics\NoPicYet.jpg")

so to call a function without returning a value just ditch the parentheses.

I think this should do it

--
Jack Leach
www.tristatemachine.com

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



tstew said:
Thank You, Jack. I've looked at the ShellExecute API, and that is over my
head.

I'm trying to use the Shell() function with the following code:

Private Sub PicPic_DblClick(Cancel As Integer)

If IsNull(Me.Pic_Location) Or (Me.Pic_Location) = "*No*" Then

Shell (CurrentProject.Path & "\Pics\NoPicYet.jpg")
Else: Shell (CurrentProject.Path & "\Pics\" & [Pic_Location] & ".jpg")

End If

End Sub

Don't laugh, it didn't work. I get an "error #5 Invalid procedure call or
argument." Any ideas why?

Thanks,
Mark



:

Application.Hyperlink defaults to opening a file as if it were clicked
through a webpage (hence the hyperlink). For instance, if I open a jpg with
AppHyperlink it opens in IE instead of my registered program.

Use the builtin Shell() function or even better, the ShellExecute API which
can be found at mvps.org/access, both of these will open the file using the
registered application.

hth
--
Jack Leach
www.tristatemachine.com

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



:

Hello,

I have a form with a linked picture. I'm trying to make a double click event
to open the picture with Windows Picture and Fax Viewer. JPG's are associated
to open with that program.

The code is:

Private Sub PicPic_DblClick(Cancel As Integer)

Application.FollowHyperlink CurrentProject.Path & "\Pics\" &
[Pic_Location] & ".jpg"

End Sub

I get the following error message...

"Run-time error '490': Cannot open the specified file."

Any ideas why?

Thanks,
Mark
 

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