• Subject: Using VBA to send Word document as body of message works in 2007, but not in 2003
  • Author: Doug Robbins - Word MVP
  • Date: 13 Feb 2010
  • References:
Based on Sue Mosher's code at
http://www.outlookcode.com/codedetail.aspx?id=1333, the following code,
which is located inside a With ActiveDocument - End With construction, works
fine in Word 2007:

Set objDoc = .MailEnvelope.Item
With objDoc
.To = strEmail
.Subject = strSubject
.Save
strID = .EntryID
End With
Set objDoc = Nothing
Set objDoc =
oOutlookApp.Session.GetItemFromID(strID)
With objDoc
.Send
End With
Set objDoc = Nothing

ObjDoc is declared as an Object and strID as a String and earlier in the
code there is the following:

On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

In Word 2003 however, it does not work and testing for strID using MsgBox
strID after it is set to .EntryID, I just get an empty message box so that
it appears that .EntryID is not being assigned.

Any clues on how to overcome this?

Regards,
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
13 Feb 2010Using VBA to send Word document as body of message works in 2007, but not in ....Doug Robbins - Word MVP
14 Feb 2010\ Re: Using VBA to send Word document as body of message works in 2007, but not....Doug Robbins - Word MVP
14 Feb 2010   \ Re: Using VBA to send Word document as body of message works in 2007, but not....Sue Mosher [MVP]
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)