Article ID: 165139
Article Last Modified on 1/19/2007
APPLIES TO
- Microsoft Outlook 97 Standard Edition
This article was previously published under Q165139
SUMMARY
In Microsoft Outlook, Contacts are listed in the Address Book in "Firstname, Lastname" order by default. This order can be toggled to "Lastname, Firstname" using the procedure outlined in this article.
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:
Follow these steps to create a new mail form that will allow you to toggle the contacts listed in the Address Book between "Firstname Lastname" and "Lastname, Firstname" order:
Design a New Mail Form
- Open a new mail message:
- On the File menu, point to New, and then click Mail Message to open a new mail message.
- On the Tools menu of the new mail message, click Design Outlook Form.
- Insert two Command Buttons on the new form:
- Click the (P.2) tab to go to a blank page on the form.
- On the Form menu, click Control Toolbox.
- On the Toolbox dialog box click CommandButton and drag it to the blank form page.
- Right-click the CommandButton1 and click Properties.
- In the Caption window type "Last, First" and click OK.
- On the Toolbox dialog box click CommandButton and drag a second button to the blank form page.
- Right-click the CommandButton2 and click Properties.
- In the Caption window type "First Last" and click OK.
- Insert Visual Basic Scripting Edition (VBScript) code:
- On the Form menu, click View Code to open the Script Editor.
In the Script Editor, type or copy the following code:
Sub CommandButton1_Click() 'This will sort ONLY contacts in CURRENT folder by LastName, FirstName 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) If Trim(MyItem.LastNameandFirstName)<>"" Then MyItem.Subject=MyItem.LastNameandFirstName MyItem.Save End If Next MsgBox "Done sorting Outlook Address Book contacts by Last" & _ " Name!",64,"Contact Tools Message" Else MsgBox "The current folder is not a Contact folder.",64,"Contact" & _ "Tools Message" End If End Sub Sub CommandButton2_Click() 'This will reset contacts in CURRENT folder to FirstName LastName 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) If Trim(MyItem.FullName)<>"" Then MyItem.Subject=MyItem.FullName MyItem.Save End If Next MsgBox "Done sorting Outlook Address Book contacts by First" & _ " Name!",64,"Contact Tools Message" Else MsgBox "The current folder is not a Contact folder.",64,"Contact" & _ " Tools Message" End If End Sub
- On the Script Editor File menu, click Close to return to the form.
- Rename the second page tab and publish the new form:
- On the Form menu, click Rename Page.
- Type a meaningful name for this page such as, Reorder Names, and click OK.
- On the File menu, click Publish Form As.
- In the Form Name box, type a meaningful name for your new form such as, Reorder Address Book Names. Ensure that next to the Publish In button you see Personal Forms, and then click the Publish button.
- Close the message without saving.
To Use Your New Form
Follow these steps to use your new form:
- Navigate to the Contact folder you wish to re-sequence.
- On the Contact menu, click Choose Form.
- In the Personal Forms list, click your new form and click OK.
- Click the second page tab and click the appropriate button to sequence the contacts in the desired order within the Address Book.
This only affects contact names in the current folder, and only those names when viewed in the Address Book. It has no effect on the order of names within any of the Contact List views.
NOTE: The ability to sort the entire Contacts Address Book using the FileAs field was added to the Microsoft Office Service Release 2 (SR-2). For information on SR-2, please see the following article in the Microsoft Knowledge Base:
151261 OFF97: How to Obtain and Install MS Office 97 SR-2
REFERENCES
For more information about creating solutions with Microsoft Outlook 97, please see the following articles in the Microsoft Knowledge Base:
166368 OL97: How to Get Help Programming with Outlook
170783 OL97: Q&A: Questions about Customizing or Programming Outlook
Additional query words: OutSol OutSol97
Keywords: kbhowto kbsample kbusage KB165139