VBOffice

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: 26.877  | #108
◀ Previous sample Next sample ▶
SAM SAM
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.

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
  Else
    Set Dlg = Application.FileDialog(msoFileDialogSaveAs)
    Dlg.Show
    If Dlg.SelectedItems.Count Then
      Fullname = Dlg.SelectedItems(1)
      ActiveDocument.SaveAs Fullname
    Else
      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
  Mail.Display
End Sub
Category-Manager Category-Manager
With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.
email  Send a message