Send a Word Document As an Attachment

See how to send a document from within Word without blocking the Outlook window.

Last modified: 2014/10/14 | Accessed: 23.119  | #108
◀ Previous sample Next sample ▶
OLKeeper OLKeeper
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.

Word supports to send the active document as an attachment to Outlook, which you can send then with an email. However, the email window opens in a modal state, which means other Outlook windows are blocked as long as the email is being displayed. During that time you cannot look at your calendar, for instance, or copy some data from another email. There's more Outlook features that don't work, for instance, automatically adding your signature to the email created by Word.

This VBA macro for Word bypasses the limitations. Open the VBA editor in Word, add a standard module to the "Normal" project, and paste the code there. You can start the macro from the document by pressing alt+f8.

The macro expects Outlook to be running already. If the Word document is saved yet, the email with the attached document will be created immediately else you'll be asked to save the document first.

tip  How to add macros to Outlook
Public Sub AttachToEmail()
  Dim Outlook As Object
  Dim Mail As Object
  Dim Att As Object
  Dim Fullname As String
  Dim Dlg As Office.FileDialog

  If ActiveDocument.Saved Then
    Fullname = ActiveDocument.Fullname
    Set Dlg = Application.FileDialog(msoFileDialogSaveAs)
    If Dlg.SelectedItems.Count Then
      Fullname = Dlg.SelectedItems(1)
      ActiveDocument.SaveAs Fullname
      Exit Sub
    End If
  End If

  Set Outlook = GetObject(, "outlook.application")
  Set Mail = Outlook.CreateItem(0)
  Set Att = Mail.Attachments.add(Fullname)
  Mail.Subject = Att.DisplayName
End Sub
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.
email  Send a message