Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

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

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.

  • 2
  • 2
1 Solution
Neil RussellTechnical Development LeadCommented:
Why not just create a file association and the double click the attachment?
willsherwoodAuthor Commented:
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...

David LeeCommented:
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

willsherwoodAuthor Commented:
a great approach, thanks!
David LeeCommented:
You're welcome.  Glad I could help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now