共用方式為


Application.GetAddress 方法 (Word)

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

語法

表情GetAddress (NameAddressPropertiesUseAutoTextDisplaySelectDialogSelectDialogCheckNamesDialogRecentAddressesChoiceUpdateRecentAddresses)

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

參數

名稱 必要/選用 資料類型 描述
Name 選用 Variant The name of the addressee, as specified in the Search Name dialog box in the address book.
地址屬性 選用 Variant UseAutoText,此參數表示定義通訊錄屬性序列的自動文字條目名稱。 若 UseAutoTextfalse 或省略,則此參數定義自訂版面。

有效的通訊錄物業名稱或物業名稱集合會被) ("<" and ">" 角括號包圍,並以空格或段落 (標記分隔,例如 "<PR_GIVEN_NAME> <PR_SURNAME>" & vbCr & "<PR_OFFICE_TELEPHONE_NUMBER>") 。

若省略 AddressProperties 參數,則會使用名為「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 指定定義一連串通訊錄屬性的自動文字條目名稱,則為真;若指定自訂版面配置,則為假
DisplaySelectDialog 選用 Variant 指定是否會顯示「 選擇名稱 」對話框,如 結果 表所示。
SelectDialog 選用 Variant 指定選擇 名稱 對話框應如何顯示, (顯示模式) ,如 顯示模式表 所示。
CheckNamesDialog 選用 Variant Name 參數的值不夠具體時,顯示「檢查名稱」對話框是正確的
最近地址選擇 選用 Variant True 可使用的清單最近使用過地址。
更新最近地址 選用 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 支援與意見反應