EnvelopeVisible Method using VBA in Word 2002

Posted on 2007-08-09
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
    LVL 65

    Expert Comment

    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

    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

    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.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Welcome to part one of a multi-part tutorial series, VBScript for Windows System Administrators.  The goal of this series is to teach non-programmers how to write useful VBS code to automate their environment, and perform tasks faster, and in a more…
    This script will sweep a range of IP addresses (class c only, and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now