Word) (Application.GetAddress 方法

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

語法

運算式GetAddress (NameAddressPropertiesUseAutoTextDisplaySelectDialogSelectDialogCheckNamesDialogRecentAddressesChoiceUpdateRecentAddresses)

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

參數

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

有效的通訊錄屬性名稱或屬性名稱集合會以角括弧括住 () "<" 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 方法。
UseAutoText 選用 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 支援與意見反應