OL2002: How to Set the Business Address as the Mailing Address (294366)



The information in this article applies to:

  • Microsoft Outlook 2002

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: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: 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

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

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.

REFERENCES

For additional information about available resources and answersto commonly asked questions about Microsoft Outlook solutions, click the article number below to view the article in the Microsoft Knowledge Base:

287530 OL2002: Questions About Custom Forms and Outlook Solutions


Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kbhowto KB294366