Windows XP & 7  Outlook (2007) Email attachments - opening in applications

Posted on 2011-02-10
Last Modified: 2012-05-11
How can i drag an attachment (as if it were already a windows filesystem file) and drop into an application for opening from an Outlook message.
Currently i have to use some waystation to launder it to get a file handle and then drag that into an application.
Currently I have to SAVE-AS the file first:  For instance, dragging to desktop or filing someplace and then going thru the motions to SAVE AS again, but when the dialog Choose File comes up, click on the now-visible  same file that i just put there and then drag that file handle into the application to open it.

This seems like a simple thing for Outlook and/or Windows to do behind the scenes to make a file "available" via a convenient dragging operation.

Question by:willsherwood
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 37

Expert Comment

by:Neil Russell
ID: 34864847
Why not just create a file association and the double click the attachment?

Author Comment

ID: 34864912
yes that would normally work fine.
However, for the cases that i have as a graphic designer, i may want to open PDFs in Photoshop (in order to convert)  or a zip file in stuffit, etc.

An alternative would be to find out how to add to the right click context menu to include OpenWith for choices - that would cover 90% of the situations...

LVL 76

Accepted Solution

David Lee earned 500 total points
ID: 34870287
Hi, wilsherwood.

It's possible to do this with a bit of scripting.  The script below will add an item to the file attachment context menu that opens the selected item in Microsoft Word.  You can add as many selections as you think is practical.

Follow these instructions to add the code to Outlook.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
5.  Edit the code as needed.  I included comment lines wherever something needs to or can change
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools > Trust Center
9.  Click Macro Security
10. Set Macro Security to "Warnings for all macros"
11. Click OK
12. Close Outlook
13. Start Outlook.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

Dim objSelectedAttachments As AttachmentSelection

Private Sub Application_AttachmentContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Attachments As AttachmentSelection)
    Dim ofcBtn As Office.CommandBarButton
    Set objSelectedAttachments = Attachments
    '--- Duplicate this block of code once for each menu selection you want to add ---'
    Set ofcBtn = CommandBar.Controls.Add(msoControlButton, , , , True)
    With ofcBtn
        .Style = msoButtonCaption
        '--- On the next line, edit the caption as needed ---'
        .Caption = "Open with Word"
        '--- On the next line change the procedure name to match the procedure that will open this type of file ---'
        .OnAction = "Project1.ThisOutlookSession.OpenWithWord"
    End With
    '--- End block ---'
    Set ofcBtn = Nothing
End Sub

'--- Create a procedure like this for each different opener ---'
Sub OpenWithWord()
    '--- On the next line change the name/path of the executable that will open this type of file ---'
    Const CMD_LINE = "Winword.exe"
    Dim objShell As Object, objItem As Object, strTempFolderPath As String
    strTempFolderPath = Environ("TEMP")
    Set objShell = CreateObject("WScript.Shell")
    For Each objItem In objSelectedAttachments
        objItem.SaveAsFile strTempFolderPath & "\" & objItem.FileName
        objShell.Exec CMD_LINE & " " & strTempFolderPath & "\" & objItem.FileName
    Set objShell = Nothing
End Sub

Open in new window


Author Closing Comment

ID: 34870743
a great approach, thanks!
LVL 76

Expert Comment

by:David Lee
ID: 34871258
You're welcome.  Glad I could help.

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question