Link to home
Start Free TrialLog in
Avatar of steven_sanders
steven_sanders

asked on

EnvelopeVisible Method using VBA in Word 2002

One question. None of the VB gurus at the office have been able to answer it.

The following simple macro works perfectly when run from the play macros dialogue box in Word 2002:

Sub Visible()
    ActiveWindow.EnvelopeVisible = Not ActiveWindow.EnvelopeVisible
End Sub

However, when linked to a button using the following script:
Private Sub CommandButton1_Click()
Call Visible
End Sub

The same code which worked perfectly before now results in the following error message:
"Run-time error '4641': Method 'EnvelopeVisisble' of object 'Window' failed"

How do I fix this problem so I can launch the visible () macro above from a button?

Avatar of RobSampson
RobSampson
Flag of Australia image

This property has no effect if the document isn't an e-mail message.  Where you have your button, is that an email message? Or another document window?  If it's a separate document, you should switch to your email document before changing the EnvelopeVisible property, with something like
Application.Window("email document").Activate

where "email document" is the file name of the email document.

Regards,

Rob.
Avatar of steven_sanders
steven_sanders

ASKER

I am aware that the property has no effect if the document is not an email message. What intrigues me is that if you run the simple Visible () macro above from the Word Macro dialogue box or from an assigned keyboard shortcut. Whether or not the document is an email message, it successfully opens the email header in Word 2002.

Yet, when you assign this same macro to a button in that word document and run it, the process fails and results in an error.

Can you explain this effect. If you can, I already know how I can utilize this technique to disarm the annoying Outlook permissions requests (e.g. the "Yes" problem) that often occur when I attempt to automate Outlook from other microsoft applications. Of course, if you know of an easier way to disable these Outlook permissions requests such that users I disseminate this application to will not have to first install third-party software: that would be great as well.

Thanks for your efforts thus far. They are duly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial