This is the code. I followed instructions from the MVP site. And Yes, I
already checked; the "Microsoft Outlook 11.0 Object Library is checked on.
I'm using Word 2003 on Windows XP 2002 SP2. The original document will be
protected when completed then saved as a template .dot file for other users
to fill out like a form and submit via email as an attachment.
Private Sub SendDocumentAsAttachment()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = "(e-mail address removed)"
.Subject = "PO# " & ActiveDocument.FormFields("POrequired").Result _
& " " & ActiveDocument.FormFields("CLIENTrequired").Result _
& " " & ActiveDocument.FormFields("PRODUCTrequired").Result
'Add the document as an attachment, you can use the .displayname property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
DisplayName:="Document as attachment"
.Display
End With
If bStarted Then
oOutlookApp.Quit
End If
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
End Sub