Microsoft KB Archive/81171

-

{|
 * width="100%"|

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 &quot;x,&quot; and you should insert the correct number of combobox1$(X) =&quot;&quot; entries for each AutoText entry that you want listed.

Word versions 6.x, 7.x
 On the Tools menu, choose Macro. Select Normal.dot (Global Template) from the Macros Available In list. In the Macro Name box, type &quot;ToolsCreateEnvelope&quot; (without the quotation marks), and click Create.  Change the text of the ToolsCreateEnvelope macro to read as follows: Sub MAIN Dim Combobox1$(2) combobox1$(0) = &quot;HomeAddress&quot; combobox1$(1) = &quot;Business&quot; combobox1$(2) = &quot;Other&quot; Begin Dialog UserDialog 320, 144, &quot;Microsoft Word&quot; 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  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. On the File menu, click Save All. (If you are prompted to save changes to Normal.dot, click Yes.) Create AutoText entries named &quot;HomeAddress,&quot; &quot;Business,&quot; and &quot;Other.&quot;

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
 From the Tools menu, choose Macro.</li> Under Show, select Global Macros. In the Macro Name box, type &quot;ToolsCreateEnvelope&quot; (without the quotation marks), and click Edit.</li>  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) </li> 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.</li> On the File menu, click Save All. Click Yes when prompted to save global glossary and command changes.</li> Create glossary entries named &quot;HomeAddress,&quot; &quot;Business,&quot; and &quot;Other.&quot;</li></ol>