EnvelopeVisible Method using VBA in Word 2002

Posted on 2007-08-09
Medium Priority
Last Modified: 2012-08-13
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?

Question by:steven_sanders
  • 2
LVL 65

Expert Comment

ID: 19667078
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.



Author Comment

ID: 19667539
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.
LVL 65

Accepted Solution

RobSampson earned 1500 total points
ID: 19667686
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.



Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question