Keyboard shortcut to open Outlook attachment

G

Guest

Is there a keyboard shortcut or vba macro code to open an Outlook attachment
within a message instead of double clicking using the mouse?
 
G

Guest

The hard way is to save the attachment to disk, then call the Shell function
to launch it. However, you need to know the path to the file's .exe handler.
Even that is tricky, because the argument specifications for the .exe could
be unique. There's also no way that I know of to retrieve the .exe path of a
registered application for a particular file extension.

--
Eric Legault - B.A, MCP, MCDBA, MCSD (VS 6.0), Outlook MVP
Try Picture Attachments Wizard - http://tinyurl.com/ckytm
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
 
M

Michael Bauer

Am Thu, 8 Sep 2005 09:03:02 -0700 schrieb Eric Legault [MVP - Outlook]:

Hi Eric,

if there´s a registered app for a file extension then you don´t need the exe
handler. Just call ShellExecute with the file´s path and, e.g., the "open"
command.
 
G

Guest

Good call Michael. I thought I had figured this out before, but I obviously
forgot! I think the differences between Shell and ShellExecute has made me
foggy.

Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String _
, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal
nShowCmd As Long) As Long

Sub OpenFile()
Dim strFileName As String
Dim lngRet As Long

strFileName = "C:\Temp\test.doc"
lngRet = ShellExecute(0, "open", strFileName, "", "", 0)
End Sub


Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String _
, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal
nShowCmd As Long) As Long

Sub OpenFile()
Dim strFileName As String
Dim lngRet As Long

strFileName = "C:\Temp\test.doc"
lngRet = ShellExecute(0, "open", strFileName, "", "", 0)
End Sub

--
Eric Legault - B.A, MCP, MCDBA, MCSD (VS 6.0), Outlook MVP
Try Picture Attachments Wizard - http://tinyurl.com/ckytm
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


Michael Bauer said:
Am Thu, 8 Sep 2005 09:03:02 -0700 schrieb Eric Legault [MVP - Outlook]:

Hi Eric,

if there´s a registered app for a file extension then you don´t need the exe
handler. Just call ShellExecute with the file´s path and, e.g., the "open"
command.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
The hard way is to save the attachment to disk, then call the Shell function
to launch it. However, you need to know the path to the file's .exe handler.
Even that is tricky, because the argument specifications for the .exe could
be unique. There's also no way that I know of to retrieve the .exe path of a
registered application for a particular file extension.
 

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