WD:Macro to Select Envelope Return Address from AutoText Entries

Last reviewed: February 2, 1998
Article ID: Q81171

The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Word for the Macintosh, versions 6.0, 6.0.1

SUMMARY

The Create Envelope command in Microsoft Word allows you to specify a mailing address and return address for an envelope. In certain situations, you may want to choose from several return addresses. This article includes a macro that displays AutoText entries from which you can select a return address.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/supportnet/refguide/ 

The first few lines of the macro determine how many AutoText entries you want to choose from and what their names are. You should customize the Dim Combobox1$(x) line by substituting the correct number of AutoText entries for "x," and you should insert the correct number of combobox1$(X) ="" entries for each AutoText entry that you want listed.

Word versions 6.x, 7.x

  1. On the Tools menu, choose Macro.

  2. Select Normal.dot (Global Template) from the Macros Available In list. In the Macro Name box, type "ToolsCreateEnvelope" (without the quotation marks), and click Create.

  3. Change the text of the ToolsCreateEnvelope macro to read as follows:

       Sub MAIN
          Dim Combobox1$(2)
          combobox1$(0) = "HomeAddress"
          combobox1$(1) = "Business"
          combobox1$(2) = "Other"
          Begin Dialog UserDialog 320, 144, "Microsoft Word"
             ComboBox 10, 6, 160, 108, ComboBox1$(), .ComboBox1
             OKButton 211, 23, 88, 21
             CancelButton 211, 47, 88, 21
          End Dialog
          Dim dlg As UserDialog
          dlg.combobox1 = combobox1$(0)
          x = Dialog(dlg)
          If x = 0 Then Goto theend
          Dim dlg2 As ToolsCreateEnvelope
          GetCurValues dlg2
          a$ = GetAutoText$(dlg.combobox1)
          dlg2.EnvReturn = a$
          n = Dialog(dlg2)
          If n <> 0 Then ToolsCreateEnvelope dlg2
       theend:
       End Sub
    
    

  4. Press CTRL+F4 to close the macro-editing window. (Press COMMAND+F4 on the Macintosh). Click Yes when prompted to save changes to Global:ToolsCreateEnvelope.

  5. On the File menu, click Save All. (If you are prompted to save changes to Normal.dot, click Yes.)

  6. Create AutoText entries named "HomeAddress," "Business," and "Other."

When you run the above macro, a dialog box prompts you to select an AutoText entry name. Select an entry and click OK. The contents of the AutoText entry are inserted into the Return Address edit box.

Word 2.x

  1. From the Tools menu, choose Macro.

  2. Under Show, select Global Macros. In the Macro Name box, type "ToolsCreateEnvelope" (without the quotation marks), and click Edit.

  3. Change the text of the ToolsCreateEnvelope macro as in step 3 of the Word 6.x, 7.x procedure above, except change the following macro command

          a$ = GetAutoText$(dlg.combobox1)
    

    to:

          a$ = GetGlossary$(dlg.combobox1)
    

  4. Press CTRL+F4 to close the macro-editing window. (Press COMMAND+F4 on the Macintosh). Click Yes when prompted to keep the changes to Global:ToolsCreateEnvelope.

  5. On the File menu, click Save All. Click Yes when prompted to save global glossary and command changes.

  6. Create glossary entries named "HomeAddress," "Business," and "Other."

REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, pages 165, 174, 228

"Microsoft Word for Windows and OS/2 Technical Reference," pages 143, 150, 192


Additional query words: tool bar toolbar winword2
Keywords : kbenvelope kbmacroexample macword ntword winword word6 word7 word95 wordnt kbmacro
Version : WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1,6.0.6.0.1a
Platform : MACINTOSH Win95 WINDOWS winnt
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.