Runtime Error: MailEnvelope

J

John

I have a userform that inserts data into bookmarks in a word document. At
the end of the routine I insert some details into and displays the
MailEnvelope.

All all works fine on my PC, but when a collegue runs it the following error
is displayed:

Run-time '-2147467262 (80004002)':

The operation failed

This error occurs on this line: .Item.to = "(e-mail address removed)"

Here is the code for the relevant section:

Dim strSubject As String
Dim env As Office.MsoEnvelope

strSubject = "Email Subject"

Set env = ActiveDocument.MailEnvelope
With env

.Introduction = "Insert some text"
.Item.subject = strSubject
.Item.to = "(e-mail address removed)"
End With
Set env = Nothing
ActiveWindow.EnvelopeVisible = Not ActiveWindow.EnvelopeVisible

Another person gets this error:

Run-time error '-2147467259 (80004005)'

Method 'MailEnvelope' of object '_Document' failed

Which happens on this line of the above code: Set env =
ActiveDocument.MailEnvelope

Any ideas?
 
C

Cindy M.

Hi John,

Is everyone using the same versin of Word? The .Envelope property is a fairly
recent addition to the Word object model (2003, I think)...
I have a userform that inserts data into bookmarks in a word document. At
the end of the routine I insert some details into and displays the
MailEnvelope.

All all works fine on my PC, but when a collegue runs it the following error
is displayed:

Run-time '-2147467262 (80004002)':

The operation failed

This error occurs on this line: .Item.to = "(e-mail address removed)"

Here is the code for the relevant section:

Dim strSubject As String
Dim env As Office.MsoEnvelope

strSubject = "Email Subject"

Set env = ActiveDocument.MailEnvelope
With env

.Introduction = "Insert some text"
.Item.subject = strSubject
.Item.to = "(e-mail address removed)"
End With
Set env = Nothing
ActiveWindow.EnvelopeVisible = Not ActiveWindow.EnvelopeVisible

Another person gets this error:

Run-time error '-2147467259 (80004005)'

Method 'MailEnvelope' of object '_Document' failed

Which happens on this line of the above code: Set env =
ActiveDocument.MailEnvelope

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
N

Nikolay Huber

I've just had the same issue and managed to resolve it. In Word VBA, when accessing the object "ActiveDocument.MailEnvelope", an exception occurs: "Method 'MailEnvelope' of object '_Document' failed". This started happening to me after I installed and then uninstalled MS Office Project 2010 (while other Office application are from MS Office 2007).

I tried to run the same code not as a macro in Word, but as an independent VBScript (a *.vbs file). In this case, the error message was "Library not registered". I think that either Word or Outlook is unable to load the library which is responsible for work with MailEnvelope.

What I've done - I monitored registry and file activities of processes winword.exe and outlook.exe at the moment when the property "ActiveDocument.MailEnvelope" is accessed. I found out that Word reads registry entries which remained from the removed installation of MS Project 2010. In my case, under the key HKEY_CLASSES_ROOT\TypeLib\{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}, there were subkeys '2.3', '2.4', and '2.5' (which I identified, based on their contents, as relating to Office 2003, 2007, and 2010, correspondingly). Deleting the subkey '2.5' resolved the problem in my case.
 
Joined
Jan 20, 2020
Messages
1
Reaction score
0
I've just had the same issue and managed to resolve it. In Word VBA, when accessing the object "ActiveDocument.MailEnvelope", an exception occurs: "Method 'MailEnvelope' of object '_Document' failed". This started happening to me after I installed and then uninstalled MS Office Project 2010 (while other Office application are from MS Office 2007).

I tried to run the same code not as a macro in Word, but as an independent VBScript (a *.vbs file). In this case, the error message was "Library not registered". I think that either Word or Outlook is unable to load the library which is responsible for work with MailEnvelope.

What I've done - I monitored registry and file activities of processes winword.exe and outlook.exe at the moment when the property "ActiveDocument.MailEnvelope" is accessed. I found out that Word reads registry entries which remained from the removed installation of MS Project 2010. In my case, under the key HKEY_CLASSES_ROOT\TypeLib\{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}, there were subkeys '2.3', '2.4', and '2.5' (which I identified, based on their contents, as relating to Office 2003, 2007, and 2010, correspondingly). Deleting the subkey '2.5' resolved the problem in my case.
Nikolay Huber,
Thank you very much,
It is 9 years later but i faced same issue in my company, some of the PC's had problems sending mails from excel.
Debugging showed the same issue "Method 'MailEnvelope' of object '_Document' failed" .

In registers i had 2.6, 2.7 and empty 2.8.

After deleting 2.8 it immediately worked.
Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top