• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1601
  • Last Modified:

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?

0
steven_sanders
Asked:
steven_sanders
  • 2
1 Solution
 
RobSampsonCommented:
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.
0
 
steven_sandersAuthor Commented:
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.
0
 
RobSampsonCommented:
Firstly, I'm wondering if such a generic procedure name like Visible() is causing a problem....try making it something that's not part of Word's reserved keywords, like EH_Visible()

Secondly, you could use CDO to send the email, rather than an Outlook.Application object.
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Access_Coding-Macros/Q_22664033.html

Regards,

Rob.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now