Condividi tramite


AddressBookName Property

Returns or sets a String that indicates the Address Book name for the MAPIFolder object representing a contact items folder. Read/write.

expression.AddressBookName

*expression   * Required. An expression that returns a MAPIFolder object representing a contact items folder.

Remarks

If you try to set the AddressBookName property in a non-Contacts items folder, an error will be returned.

Example

The following example changes the Address Book name for the contact items folder and displays the new name to the user. The subroutine accepts the folder object and a String representing the new address book name.

Sub BookName()

    Dim olApp As Outlook.Application
    Dim nmsName As Outlook.NameSpace
    Dim fldFolder As Outlook.MAPIFolder
    Dim strAns As String

    Set olApp = New Outlook.Application
    'Create a reference to namepsace
    Set nmsName = olApp.GetNamespace("MAPI")
    'Create an instance of the Contacts folder
    Set fldFolder = nmsName.GetDefaultFolder(olFolderContacts)
    'Prompt user for input
    strAns = InputBox("Type the name of the new address book")
    'Call Sub procedure
    Call Changebook(fldFolder, strAns)

End Sub

Sub Changebook(ByRef fldFolder As MAPIFolder, ByVal strName As String)
'Changes the name of the address book for a given folder

    'Set address book name to user input
    fldFolder.AddressBookName = strName
    'Display message to user
    MsgBox ("The new address book name for the " & fldFolder.Name & " folder is " _
             & strName & ".")

End Sub

Applies to | MAPIFolder Object

See Also | AddressEntries Object | AddressEntry Object | AddressList Object | AddressLists Object