Microsoft KB Archive/294366

= OL2002: How to Set the Business Address as the Mailing Address =

Article ID: 294366

Article Last Modified on 11/23/2006

-

APPLIES TO


 * Microsoft Outlook 2002 Standard Edition

-



This article was previously published under Q294366





SUMMARY
This article describes how to set the Business Address of all contact items in a folder as the default mailing address by using Visual Basic Scripting Edition (VBScript).



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 professionals 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 a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

https://partner.microsoft.com/global/30000104

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

To create a new Post form to set the business address as the default mailing address for all contact records in a folder:

Design a New Post Form
 Open a new post message:  On the File menu of the Inbox, point to New, and then click Post in This Folder. In the new Post form, on the Tools menu, point to Forms, and then click Design This Form.  Insert a Command button on the new form:  Click the (P.2) tab to go to a blank page on the form.</li> On the Form menu, click Control Toolbox.</li> In the Control Toolbox, click CommandButton, and then drag it to the blank form page.</li> Right-click CommandButton1, and then click Properties.</li> In the Caption box, type Set Mailing Addresses, and then click OK.</li></ol> </li> Insert VBScript code:  On the Form menu, click View Code to open Script Editor.</li>  In Script Editor, type the following code: Sub CommandButton1_Click CONST olNone = 0 CONST olHome = 1 CONST olBusiness = 2 CONST olOther = 3 'This will only work on contacts in the current folder Set CurFolder=Application.ActiveExplorer.CurrentFolder If CurFolder.DefaultItemType=2 Then MsgBox &quot;This process may take some time. You will be notified&quot; & _ &quot; when complete.&quot;,,&quot;Contact Tools Message&quot; Set MyItems = CurFolder.Items For i = 1 to MyItems.Count Set MyItem = MyItems.Item(i) MyItem.SelectedMailingAddress = olBusiness MyItem.Save Next MsgBox &quot;Done!&quot;,64,&quot;Contact Tools Message&quot; Else MsgBox &quot;The current folder is not a Contact folder.&quot;,64,&quot;Contact&quot; & _ &quot; Tools Message&quot; End If End Sub </li> In the Script Editor, on the File menu, click Close to return to the form.</li></ol> </li> Rename the second page (P.2) tab and publish the new form:  On the Form menu, click Rename Page.</li> Type a name for this page, such as Set Mailing Addresses, and then click OK.</li> On the Tools menu, point to Forms, and then click Publish Form As.</li> In the Display Name box, type a name for your new form, such as Set Mailing Addresses .</li> In the Look In drop-down list box, click Personal Forms Library.</li> <li>Click Publish to publish the form.</li> <li>If you are prompted to check the Save Form Definition with Item check box, click No.</li> <li>Close the message without saving your changes.</li></ol> </li></ol>

To Use Your New Form

 * 1) Find the folder that contains the contacts that you want to update.
 * 2) On the File menu, point to New, and then click Choose Form.
 * 3) In the Look In drop-down list box, click Personal Forms Library.
 * 4) Click your new form in the list, and then click Open.
 * 5) Click the second page tab, and then click the Set Mailing Addresses button (from Step 2e above) to set the business address as the default mailing address for all contacts in the current folder.

<div class="references_section">