Share via


GetAddress Method

Returns an address from the default address book.

expression**.GetAddress(Name**, AddressProperties, UseAutoText, DisplaySelectDialog, SelectDialog, CheckNamesDialog, RecentAddressesChoice, UpdateRecentAddresses)

expression Required. An expression that returns an Application object.

Name    Optional Variant. The name of the addressee, as specified in the Search Name dialog box in the address book.

AddressProperties    Optional Variant. If UseAutoText is True, this argument denotes the name of an AutoText entry that defines a sequence of address book properties. If UseAutoText is False or omitted, this argument defines a custom layout. Valid address book property names or sets of property names are surrounded by angle brackets ("<" and ">") and separated by a space or a paragraph mark (for example, "<PR_GIVEN_NAME> <PR_SURNAME>" & vbCr & "<PR_OFFICE_TELEPHONE_NUMBER>").

If this argument is omitted, default AutoText entry named "AddressLayout" is used. If "AddressLayout" hasn't been defined, the following address layout definition is used: "<PR_GIVEN_NAME> <PR_SURNAME>" & vbCr & "<PR_STREET_ADDRESS>" & vbCr & "<PR_LOCALITY>" & ", " & "<PR_STATE_OR_PROVINCE>" & " " & "<PR_POSTAL_CODE>" & vbCr & "<PR_COUNTRY>".

For a list of the valid address book property names, see the AddAddress method.

UseAutoText    Optional Variant. True if AddressProperties specifies the name of an AutoText entry that defines a sequence of address book properties; False if it specifies a custom layout.

DisplaySelectDialog    Optional Variant. Specifies whether the Select Name dialog box is displayed, as shown in the following table.

Value Result
0 (zero) The Select Name dialog box isn't displayed.
1 or omitted The Select Name dialog box is displayed.
2 The Select Name dialog box isn't displayed, and no search for a specific name is performed. The address returned by this method will be the previously selected address.

SelectDialog    Optional Variant. Specifies how the Select Name dialog box should be displayed (that is, in what mode), as shown in the following table.

Value Display mode
0 (zero) or omitted Browse mode
1 Compose mode, with only the To: box
2 Compose mode, with both the To: and CC: boxes

CheckNamesDialog    Optional Variant. True to display the Check Names dialog box when the value of the Name argument isn't specific enough.

RecentAddressesChoice    Optional Variant. True to use the list of recently used return addresses.

UpdateRecentAddresses    Optional Variant. True to add an address to the list of recently used addresses; False to not add the address. If SelectDialog is set to 1 or 2, this argument is ignored.

Example

This example sets the variable strAddress to John Smith's address, moves the insertion point to the beginning of the document, and inserts the address. The inserted address will include the default address book properties.

Dim strAddress

strAddress = Application.GetAddress(Name:="John Smith", _
    CheckNamesDialog:=True)
ActiveDocument.Range(Start:=0, End:=0).InsertAfter strAddress

The following example returns John Smith's address, using the "My Address Layout" AutoText entry as the layout definition. "My Address Layout" is defined in the active template and contains a set of address properties assigned to the text$ variable. The example also adds John Smith's address to the list of recently used addresses.

Dim TagIDArray(0 To 3) As String
Dim ValueArray(0 To 3) As String
Dim strAddress As String

TagIDArray(0) = "PR_DISPLAY_NAME"
TagIDArray(1) = "PR_GIVEN_NAME"
TagIDArray(2) = "PR_SURNAME"
TagIDArray(3) = "PR_COMMENT"
ValueArray(0) = "Display_Name"
ValueArray(1) = "John"
ValueArray(2) = "Smith"
ValueArray(3) = "This is a comment"

Application.AddAddress TagID:=TagIDArray(), Value:=ValueArray()
strAddress = Application.GetAddress(Name:="John Smith", _
    UpdateRecentAddresses:=True)

Applies to | Application Object

See Also | AddAddress Method | LookupNameProperties Method