Using VBA to send Word document as body of message works in 2007, but not in 2003

  • Thread starter Doug Robbins - Word MVP
  • Start date
Status
Not open for further replies.
D

Doug Robbins - Word MVP

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
 
As a followup, if I remove the On Error Resume Next, the following error

message is displayed:

430 Class does not support Automation or does not support expected interface

Any clues on how to overcome this?

Regards,

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message

news:B9A296D0-5B2C-46C1-93B1-A01C9A7C0583@microsoft.com...
> 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
 
Which statement raises that error? You're running this code in Word VBA?

Sue Mosher

"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message

news:ef5ottSrKHA.5896@TK2MSFTNGP04.phx.gbl...
> As a followup, if I remove the On Error Resume Next, the following error
> message is displayed:

> 430 Class does not support Automation or does not support expected
> interface
>
> > 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?

>
 
Hi Sue,

Yes, it is being run from Word. It is in the Word 2003 version of the

add-in that can be downloaded from:

http://www.gmayor.com/ManyToOne.htm

However, in the 2003 version that is available there, the "Merge to Email

Message" facility has been disabled.

The error is being caused by the

Set objDoc = .MailEnvelope.Item

command. Note that line of code is inside a With ActiveDocument...End With

construction, and when writing the code, the intellisense provides

MailEnvelope.Item as a suggestion.

Regards,

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message

news:u7E2jHTrKHA.728@TK2MSFTNGP04.phx.gbl...
> Which statement raises that error? You're running this code in Word VBA?
> > Sue Mosher
> > >

> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> news:ef5ottSrKHA.5896@TK2MSFTNGP04.phx.gbl...
> > As a followup, if I remove the On Error Resume Next, the following error
> > message is displayed:
>

>> 430 Class does not support Automation or does not support expected
> > interface
> >
> >> 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?

> >


>
 
What does ActiveDocument.MailEnvelope return?

Sue Mosher

"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message

news:OBxY0jTrKHA.3800@TK2MSFTNGP06.phx.gbl...
> Hi Sue,

> Yes, it is being run from Word. It is in the Word 2003 version of the
> add-in that can be downloaded from:

> http://www.gmayor.com/ManyToOne.htm

> However, in the 2003 version that is available there, the "Merge to Email
> Message" facility has been disabled.

> The error is being caused by the

> Set objDoc = .MailEnvelope.Item

> command. Note that line of code is inside a With ActiveDocument...End
> With construction, and when writing the code, the intellisense provides
> MailEnvelope.Item as a suggestion.

> > Regards,

> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> news:u7E2jHTrKHA.728@TK2MSFTNGP04.phx.gbl...
> > Which statement raises that error? You're running this code in Word VBA?
>

>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> > news:ef5ottSrKHA.5896@TK2MSFTNGP04.phx.gbl...
> >> As a followup, if I remove the On Error Resume Next, the following error
> >> message is displayed:
> >
>>> 430 Class does not support Automation or does not support expected
> >> interface
> >
>>>> 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?
> >>

>

>>
 
Hi Sue,

If I insert

MsgBox ActiveDocument.MailEnvelope

into the code, or just create a macro in the normal.dot template that

contains that code, in both cases, I get the Run-Time error '430' message

Class does not support Automation or does not support expected interface.

The same error message appears if I try and run the following code from the

VBA Help File:

ActiveDocument.MailEnvelope.Introduction = _

"Please review this document and let me know " & _

"what you think. I need your input by Friday." & _

" Thanks."

I have tried deleting Registry Keys, and re-registering Word, but that did

not make any difference

I have also tried running the code from

http://www.outlookcode.com/codedetail.aspx?id=1333 from Outlook, which did

not work and if I comment out the On Error Resume Next, I get the same error

message.

BTW, this was a fresh install of Office 2003 on a machine that previously

had 2010 Beta on it, but that was uninstalled before 2003 was installed and

the Registry Keys for Office 14.0 have been deleted.

Regards,

Doug Robbins - Word MVP

"Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message

news:%23mu0mwarKHA.3792@TK2MSFTNGP05.phx.gbl...
> What does ActiveDocument.MailEnvelope return?

> > Sue Mosher
> > >

> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> news:OBxY0jTrKHA.3800@TK2MSFTNGP06.phx.gbl...
> > Hi Sue,
>

>> Yes, it is being run from Word. It is in the Word 2003 version of the
> > add-in that can be downloaded from:
>

>> http://www.gmayor.com/ManyToOne.htm
>

>> However, in the 2003 version that is available there, the "Merge to Email
> > Message" facility has been disabled.
>

>> The error is being caused by the
>

>> Set objDoc = .MailEnvelope.Item
>

>> command. Note that line of code is inside a With ActiveDocument...End
> > With construction, and when writing the code, the intellisense provides
> > MailEnvelope.Item as a suggestion.
>

>> > > Regards,
>

>> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>

>> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > news:u7E2jHTrKHA.728@TK2MSFTNGP04.phx.gbl...
> >> Which statement raises that error? You're running this code in Word VBA?
> >
>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> >> news:ef5ottSrKHA.5896@TK2MSFTNGP04.phx.gbl...
> >>> As a followup, if I remove the On Error Resume Next, the following
> >>> error message is displayed:
> >>
>>>> 430 Class does not support Automation or does not support expected
> >>> interface
> >>
>>>>> 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?
> >>
>>
>>>


>
 
Hi Sue,

While ActiveDocument.MailEnvelope also errors out in Word 2007, in that

version, ActiveDocument.MailEnvelope.Parent returns the name of the active

document, but it gives the 430 error message in Word 2003.

Also, I have now tried that on machines that have never had anything later

than Office 2003 installed on them with the same result.

Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on

a paid professional basis.

"Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message

news:%23mu0mwarKHA.3792@TK2MSFTNGP05.phx.gbl...
> What does ActiveDocument.MailEnvelope return?

> > Sue Mosher
> > >

> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> news:OBxY0jTrKHA.3800@TK2MSFTNGP06.phx.gbl...
> > Hi Sue,
>

>> Yes, it is being run from Word. It is in the Word 2003 version of the
> > add-in that can be downloaded from:
>

>> http://www.gmayor.com/ManyToOne.htm
>

>> However, in the 2003 version that is available there, the "Merge to Email
> > Message" facility has been disabled.
>

>> The error is being caused by the
>

>> Set objDoc = .MailEnvelope.Item
>

>> command. Note that line of code is inside a With ActiveDocument...End
> > With construction, and when writing the code, the intellisense provides
> > MailEnvelope.Item as a suggestion.
>

>> > > Regards,
>

>> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>

>> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > news:u7E2jHTrKHA.728@TK2MSFTNGP04.phx.gbl...
> >> Which statement raises that error? You're running this code in Word VBA?
> >
>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> >> news:ef5ottSrKHA.5896@TK2MSFTNGP04.phx.gbl...
> >>> As a followup, if I remove the On Error Resume Next, the following
> >>> error message is displayed:
> >>
>>>> 430 Class does not support Automation or does not support expected
> >>> interface
> >>
>>>>> 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?
> >>
>>
>>>


>
 
My guess is that the problem has to do with the 2010 installation. I have no

idea how to fix that. You might want to ask on the beta forum how to do a

complete uninstallation.

Sue Mosher

"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message

news:BB251675-C7E0-4172-A877-5AE61BFE3AA6@microsoft.com...
> Hi Sue,

> If I insert

> MsgBox ActiveDocument.MailEnvelope

> into the code, or just create a macro in the normal.dot template that
> contains that code, in both cases, I get the Run-Time error '430' message

> Class does not support Automation or does not support expected interface.

> The same error message appears if I try and run the following code from
> the VBA Help File:

> ActiveDocument.MailEnvelope.Introduction = _
> "Please review this document and let me know " & _
> "what you think. I need your input by Friday." & _
> " Thanks."

> I have tried deleting Registry Keys, and re-registering Word, but that did
> not make any difference

> I have also tried running the code from
> http://www.outlookcode.com/codedetail.aspx?id=1333 from Outlook, which did
> not work and if I comment out the On Error Resume Next, I get the same
> error message.

> BTW, this was a fresh install of Office 2003 on a machine that previously
> had 2010 Beta on it, but that was uninstalled before 2003 was installed
> and the Registry Keys for Office 14.0 have been deleted.

> > Regards,

> Doug Robbins - Word MVP

> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> news:%23mu0mwarKHA.3792@TK2MSFTNGP05.phx.gbl...
> > What does ActiveDocument.MailEnvelope return?
>

>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> > news:OBxY0jTrKHA.3800@TK2MSFTNGP06.phx.gbl...
> >> Hi Sue,
> >
>>> Yes, it is being run from Word. It is in the Word 2003 version of the
> >> add-in that can be downloaded from:
> >
>>> http://www.gmayor.com/ManyToOne.htm
> >
>>> However, in the 2003 version that is available there, the "Merge to
> >> Email Message" facility has been disabled.
> >
>>> The error is being caused by the
> >
>>> Set objDoc = .MailEnvelope.Item
> >
>>> command. Note that line of code is inside a With ActiveDocument...End
> >> With construction, and when writing the code, the intellisense provides
> >> MailEnvelope.Item as a suggestion.
> >
>>> > >> Regards,
> >
>>> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
> >
>>> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> >> news:u7E2jHTrKHA.728@TK2MSFTNGP04.phx.gbl...
> >>> Which statement raises that error? You're running this code in Word
> >>> VBA?
> >>
>>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> >>> news:ef5ottSrKHA.5896@TK2MSFTNGP04.phx.gbl...
> >>>> As a followup, if I remove the On Error Resume Next, the following
> >>>> error message is displayed:
> >>>
>>>>> 430 Class does not support Automation or does not support expected
> >>>> interface
> >>>
>>>>>> 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?
> >>>
>>>
>>>>

>

>>

>
 
On the pure Office 2003 machines, did you install Outlook and Word from the

same SKU? If not, I think the Office Envelope functionality (among other

features) won't work.

Also, I don't know what you mean about this code being related to the

add-in. If add-ins are present, maybe disabling them would reveal something

useful.

Sue Mosher

"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message

news:C17CA250-3146-43B1-9F42-FE559A10C2DD@microsoft.com...
> Hi Sue,

> While ActiveDocument.MailEnvelope also errors out in Word 2007, in that
> version, ActiveDocument.MailEnvelope.Parent returns the name of the active
> document, but it gives the 430 error message in Word 2003.

> Also, I have now tried that on machines that have never had anything later
> than Office 2003 installed on them with the same result.

> > Hope this helps,

> Doug Robbins - Word MVP

> Please reply only to the newsgroups unless you wish to obtain my services
> on
> a paid professional basis.

> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> news:%23mu0mwarKHA.3792@TK2MSFTNGP05.phx.gbl...
> > What does ActiveDocument.MailEnvelope return?
>

>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> > news:OBxY0jTrKHA.3800@TK2MSFTNGP06.phx.gbl...
> >> Hi Sue,
> >
>>> Yes, it is being run from Word. It is in the Word 2003 version of the
> >> add-in that can be downloaded from:
> >
>>> http://www.gmayor.com/ManyToOne.htm
> >
>>> However, in the 2003 version that is available there, the "Merge to
> >> Email Message" facility has been disabled.
> >
>>> The error is being caused by the
> >
>>> Set objDoc = .MailEnvelope.Item
> >
>>> command. Note that line of code is inside a With ActiveDocument...End
> >> With construction, and when writing the code, the intellisense provides
> >> MailEnvelope.Item as a suggestion.
> >
>>> > >> Regards,
> >
>>> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
> >
>>> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> >> news:u7E2jHTrKHA.728@TK2MSFTNGP04.phx.gbl...
> >>> Which statement raises that error? You're running this code in Word
> >>> VBA?
> >>
>>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> >>> news:ef5ottSrKHA.5896@TK2MSFTNGP04.phx.gbl...
> >>>> As a followup, if I remove the On Error Resume Next, the following
> >>>> error message is displayed:
> >>>
>>>>> 430 Class does not support Automation or does not support expected
> >>>> interface
> >>>
>>>>>> 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?
 
Thanks, Sue.

I have now determined that it must be something to do with the particular

installation of Office.

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my

services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message

news:O$jZuRdrKHA.4460@TK2MSFTNGP05.phx.gbl...
> On the pure Office 2003 machines, did you install Outlook and Word from
> the same SKU? If not, I think the Office Envelope functionality (among
> other features) won't work.

> Also, I don't know what you mean about this code being related to the
> add-in. If add-ins are present, maybe disabling them would reveal
> something useful.
> > Sue Mosher
> > >

> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> news:C17CA250-3146-43B1-9F42-FE559A10C2DD@microsoft.com...
> > Hi Sue,
>

>> While ActiveDocument.MailEnvelope also errors out in Word 2007, in that
> > version, ActiveDocument.MailEnvelope.Parent returns the name of the
> > active document, but it gives the 430 error message in Word 2003.
>

>> Also, I have now tried that on machines that have never had anything
> > later than Office 2003 installed on them with the same result.
>

>> > > Hope this helps,
>

>> Doug Robbins - Word MVP
>

>> Please reply only to the newsgroups unless you wish to obtain my services
> > on
> > a paid professional basis.
>

>> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > news:%23mu0mwarKHA.3792@TK2MSFTNGP05.phx.gbl...
> >> What does ActiveDocument.MailEnvelope return?
> >
>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> >> news:OBxY0jTrKHA.3800@TK2MSFTNGP06.phx.gbl...
> >>> Hi Sue,
> >>
>>>> Yes, it is being run from Word. It is in the Word 2003 version of the
> >>> add-in that can be downloaded from:
> >>
>>>> http://www.gmayor.com/ManyToOne.htm
> >>
>>>> However, in the 2003 version that is available there, the "Merge to
> >>> Email Message" facility has been disabled.
> >>
>>>> The error is being caused by the
> >>
>>>> Set objDoc = .MailEnvelope.Item
> >>
>>>> command. Note that line of code is inside a With ActiveDocument...End
> >>> With construction, and when writing the code, the intellisense provides
> >>> MailEnvelope.Item as a suggestion.
> >>
>>>> > >>> Regards,
> >>
>>>> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
> >>
>>>> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> >>> news:u7E2jHTrKHA.728@TK2MSFTNGP04.phx.gbl...
> >>>> Which statement raises that error? You're running this code in Word
> >>>> VBA?
> >>>
>>>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> >>>> news:ef5ottSrKHA.5896@TK2MSFTNGP04.phx.gbl...
> >>>>> As a followup, if I remove the On Error Resume Next, the following
> >>>>> error message is displayed:
> >>>>
>>>>>> 430 Class does not support Automation or does not support expected
> >>>>> interface
> >>>>
>>>>>>> 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?


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
M VBA Send Sales reports using .oft files, originate in Outlook or Excel? Using Outlook 5
S Send All emails in Outbox and Quit using VBA Outlook VBA and Custom Forms 3
H using VBA to edit subject line Outlook VBA and Custom Forms 0
Geldner Problem submitting SPAM using Outlook VBA Form Outlook VBA and Custom Forms 2
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
Z Import Tasks from Access Using VBA including User Defined Fields Outlook VBA and Custom Forms 0
justicefriends How to set a flag to follow up using VBA - for addressee in TO field Outlook VBA and Custom Forms 11
David McKay VBA to manually forward using odd options Outlook VBA and Custom Forms 1
K can't get custom form to update multiple contacts using VBA Outlook VBA and Custom Forms 3
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
O Email not leaving Outbox when using Excel VBA to sync Outlook account Outlook VBA and Custom Forms 4
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
B Vba to monitor time to respond to emails using a shared mailbox Outlook VBA and Custom Forms 5
B Looking to get the Recipient email address (or even the "friendly name") from an email I am replying to using VBA Outlook VBA and Custom Forms 4
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
D Remove text in subject using VBA Outlook VBA and Custom Forms 4
P How to export voting results using VBA? Outlook VBA and Custom Forms 2
S Find a cell value in excel using outlook vba Using Outlook 1
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
B query outlook using vba Outlook VBA and Custom Forms 13
P Replying to calendar item using VBA Outlook VBA and Custom Forms 4
H Change Default Email Account Using VBA Outlook VBA and Custom Forms 5
U Using VBA to creat hyperlinks in an email Outlook VBA and Custom Forms 3
P Outlook 2007 Email Categorization using VBA Outlook VBA and Custom Forms 1
M Multiple User Defined Fields that can be added, changed, updated using VBA and user form Outlook VBA and Custom Forms 0
Diane Poremsky Create a Series of Tasks using VBA Using Outlook 0
Diane Poremsky Paste clipboard contents using VBA Using Outlook 0
Diane Poremsky Copy New Appointments to Another Calendar using VBA Using Outlook 0
L Clear Offline (Task) Items using VBA Outlook VBA and Custom Forms 0
O How to set subject line in replies using VBA Outlook VBA and Custom Forms 1
O VBA rule on multiple computers using shared mailbox Outlook VBA and Custom Forms 1
G Adding a contact to Outlook with a custom form using Access VBA Outlook VBA and Custom Forms 1
J Using VBA to disable alerts / warnings Using Outlook 2
P Saving All Messages to the Hard Drive Using VBA Outlook VBA and Custom Forms 5
Diane Poremsky Create a list of color categories and merge or restore the list using VBA Using Outlook 0
A Can i apply mail rules to inbox sub folders using VBA Outlook VBA and Custom Forms 2
M using Folders.Count in Excel Vba Outlook VBA and Custom Forms 8
A Outlook VBA - moving mail item to public folder using variable within path Using Outlook 6
P Automatic reply on incoming messages in outlook using VBA(only Specifi person) Using Outlook 14
D Update existing rule using VBA Using Outlook 2
A VBA Script to Forward Spam to AntiSpam Provider Using "Blank" Form Outlook VBA and Custom Forms 2
J How to set a flag to follow up using VBA for outlook 2003 Using Outlook 10
J Add categories to Shared Mailbox using VBA Using Outlook 2
R Limiting meeting attendees using VBA or an add-in Using Outlook 9
J Create new outlook task into task subfolder using vba Using Outlook 6
R Outlook and Access integration using VBA Outlook VBA and Custom Forms 1

Similar threads

Back
Top