One solution was proposed in a separate thread:
http://www.microsoft.com/communitie...029523-5d34-4f55-b1e9-aea600b521c6&sloc=en-us
Here's another way of doing it - note that with both solutions you may get a
message saying that the sub is trying to access your Outlook address book.
This is a security feature and may be unavoidable given that you're trying to
control Outlook from Word. You may just have to live with it (ie users will
have to grant the sub permission to use Outlook for however many minutes they
specify in the security warning message).
As for the problem with the command button, looks like you're going to have
to create your form as a template, store the code in a module, create a
toolbar that contains a command button pointing toward your macro.
Sub SendAttachment()
Dim objOutlook As Object
Dim objMailItem As Object
Dim strFilename As String
On Error GoTo errorhandler:
With ActiveDocument
strFilename = .Path & Application.PathSeparator & .Name
End With
Set objOutlook = CreateObject("Outlook.Application")
Set objMailItem = objOutlook.CreateItem(olMailItem)
With objMailItem
',1 means add attachment as copy of file
.Attachments.Add strFilename, 1
.Recipients.Add ("(e-mail address removed)")
.Subject = "Your Subject"
.Body = "This is a sample message."
End With
objMailItem.Display
Set objMailItem = Nothing
Set objOutlook = Nothing
Exit Sub
errorhandler:
MsgBox "Cancelled"
End Sub