Application.GetAddress 方法 (Word)

傳回預設通訊錄中的地址。

語法

運算式。GetAddress (Name, AddressProperties, UseAutoText, DisplaySelectDialog, SelectDialog, CheckNamesDialog, RecentAddressesChoice, UpdateRecentAddresses)

需要 expression。 代表 Application 物件的變數。

參數

名稱 必要/選用 資料類型 描述
Name 選用 Variant The name of the addressee, as specified in the Search Name dialog box in the address book.
AddressProperties 選用 Variant 如果 UseAutoText 為 True,此引數表示定義通訊錄屬性順序的自動圖文集項目名稱。 如果 UseAutoText 為 False 或省略,則此引數會定義自訂配置。

有效的通訊錄屬性名稱或屬性名稱集合會以) ("<" and ">" 的尖括弧括住,並以空格或段落標記分隔 ("<PR_GIVEN_NAME> <PR_SURNAME>" & vbCr & "<PR_OFFICE_TELEPHONE_NUMBER>" 例如) 。

如果省略 AddressProperties 參數,則會使用名為 “AddressLayout” 的預設自動圖文集項目。 如果尚未定義 “AddressLayout”,則使用下列地址配置定義: "<PR_GIVEN_NAME> <PR_SURNAME>" & vbCr & "<PR_STREET_ADDRESS>" & vbCr & "<PR_LOCALITY>" & ", " & "<PR_STATE_OR_PROVINCE>" & " " & "<PR_POSTAL_CODE>" & vbCr & "<PR_COUNTRY>"。

如需有效通訊錄屬性名稱的清單,請參閱 AddAddress 方法。
使用自動圖文集 選用 Variant 如果 AddressProperties 指定定義通訊錄屬性順序的自動圖文集項目名稱,則為 True;如果指定自訂版面配置,則為 False。
DisplaySelectDialog 選用 Variant 指定是否顯示 [選取名稱 ] 對話方塊,如 [結果 ] 資料表所示。
SelectDialog 選用 Variant 指定 [選取名稱 ] 對話方塊的顯示方式, (也就是顯示) 的模式,如 [ 顯示模式 ] 資料表中所示。
CheckNamesDialog 選用 Variant True 以在 Name 引數的值不夠特定時顯示 [檢查名稱] 對話方塊。
RecentAddressesChoice 選用 Variant True 可使用的清單最近使用過地址。
UpdateRecentAddresses 選用 Variant True 是表示 最近新增至清單的地址使用位址 ; False 不新增地址。 如果 SelectDialog 設為 1 或 2,則會忽略此引數。

結果

值 結果
0 (零) The Select Name dialog box isn't displayed.
1 或省略 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.

顯示模式

值 顯示模式
0 (零) 或省略 瀏覽模式
1 Compose mode, with only the To: box
2 Compose mode, with both the To: and CC: boxes

傳回值

字串

範例

此範例會將變數 strAddress 設定為 John Smith 的地址,並將插入點移到文件的開頭,然後插入地址。 插入的地址將會包含預設的通訊錄屬性。

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

下列範例會使用 "My Address Layout" 自動圖文集項目做為配置定義,傳回 John Smith 的地址。 "My Address Layout" 是在使用中的範本內定義而且包含指派給 text$ 變數的地址屬性集。 此外,這則範例也會將 John Smith 的地址加入至最近使用的地址清單。

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)

另請參閱

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。