Bypass hyperlink prompt in VBA?

R

Robert Bonds

Am having a bit of a problem with the following line of VBA code activated
from a command button on a form I've designed in Access 2007:

Application.FollowHyperlink Me.DocumentFilePath

This works fine when the file being opened is a PDF, Excel file, Word
document, etc. But when the file to be opened is a saved e-mail message (.msg
file), a prompt always pops up: "Some files can contain viruses or otherwise
be harmful to your computer... It is important to be certain that this file
is from a trustworthy source. Would you like to open this file?"

Any e-mail messages being opened this way will always be from trustworthy
sources, and will already have been screened for viruses. So I'm wondering if
there's a way to bypass this prompt? It appears to be coming from outside
Access, since inserting a "DoCmd.SetWarnings False" line just before the
above code has no effect.

Any suggestions would be greatly appreciated. Thanks.
 
A

Allen Browne

You may be able to avoid the issue by using a complete hyperlink (with the
file prefix and both the display and address parts.)

This kind of thing:

Dim strDoc As String
strDoc = "file:///" & Me.DocumentFilePath & "#" & Me.DocumentFilePath
FollowHyperlink strDoc
 
J

Jack Leach

Application.FollowHyperlink has this downfall, being that the OS opens the
file as if you found it on the web somewhere. Instead, try the ShellExecute
API. I've never opened a .msg file with it, but for every other filetype
where a security prompt is present using FollowHyperlink, the API will open
it wthout warning.

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


hth

--
Jack Leach
www.tristatemachine.com

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

Robert Bonds

Jack, the ShellExecute API does the job. It works perfectly! Thanks for the
tip.

Allen, thanks for the suggestion regarding the complete hyperlink. It didn't
work in this case, but I can already think of other areas where it will come
in handy, so am glad to have your feedback.

Arvin, thanks too for telling me about Outlook Redemption. Since the
ShellExecute API worked in this limited case, I haven't explored this plug-in
yet, but it looks like it could well provide an answer to the next 937
problems on my list! So am very glad to know about this – thanks much.

Robert Bonds

======
 

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