The information in this article applies to:
SUMMARY
In Outlook 97, 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:
http://www.microsoft.com/support/supportnet/refguide/default.asp
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:
a. On the File menu, point to New, and then click Mail Message to open
a new mail message.
b. On the Tools menu of the new mail message, click Design Outlook
Form.
- Insert two Command Buttons on the new form:
a. Click the (P.2) tab to go to a blank page on the form.
b. On the Form menu, click Control Toolbox.
c. On the Toolbox dialog box click CommandButton and drag it to the
blank form page.
d. Right-click the CommandButton1 and click Properties.
e. In the Caption window type "Last, First" and click OK.
f. On the Toolbox dialog box click CommandButton and drag a second
button to the blank form page.
g. Right-click the CommandButton2 and click Properties.
h. In the Caption window type "First Last" and click OK.
- Insert Visual Basic Scripting Edition (VBScript) code:
a. On the Form menu, click View Code to open the Script Editor.
b. 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
c. On the Script Editor File menu, click Close to return to the form.
- Rename the second page tab and publish the new form:
a. On the Form menu, click Rename Page.
b. Type a meaningful name for this page such as, Reorder Names, and
click OK.
c. On the File menu, click Publish Form As.
d. 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.
e. 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.
NOTE: This only affects contact names in the current folder and then 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.
REFERENCES
For more information about creating solutions with Microsoft Outlook 97,
please see the following articles in the Microsoft Knowledge Base:
Article-ID: Q166368
Title : OL97: How to Get Help Programming with Outlook
Article-ID: Q170783
Title : OL97: Q&A: Questions about Customizing or
Programming Outlook
|