共用方式為


ApplicationFactory.CreateSmartTag 方法

建立 SmartTag 物件,這個物件表示文件上的智慧標籤。 這個型別或成員僅適用於 2007 Microsoft Office system 專案。智慧標籤在 Office 2010 中已被取代。
.

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)

語法

'宣告
Function CreateSmartTag ( _
    smartTagType As String, _
    caption As String, _
    extension As ISmartTagExtension _
) As SmartTag
SmartTag CreateSmartTag(
    string smartTagType,
    string caption,
    ISmartTagExtension extension
)

參數

  • smartTagType
    型別:System.String
    智慧標籤的唯一識別項,由命名空間 URI 和以數字符號 (#) 分隔的標籤型別名稱所組成。
  • caption
    型別:System.String
    顯示於智慧標籤功能表上的智慧標籤名稱。

傳回值

型別:Microsoft.Office.Tools.Word.SmartTag
新的智慧標籤。

例外狀況

例外狀況 條件
ArgumentException

smartTagType 或 caption 為 nullnull 參考 (即 Visual Basic 中的 Nothing)、空的,或者是 smartTagType 無效。

備註

smartTagType 參數的有效字串的範例:http://smarttags.contoso.com#TagName。 語式正確 (Well-Formed) 的智慧標籤型別字串不會包含空白字元,而且其開頭為字母 (a-z、A-Z)、底線 (_) 或冒號 (:)。

範例

下列程式碼範例示範如何在 Word 增益集專案中建立智慧標籤和動作。 若要使用這個範例,請從 ThisAddIn 類別中執行程式碼。

Dim simpleSmartTag As Microsoft.Office.Tools.Word.SmartTag =
    Globals.Factory.CreateSmartTag(
        "www.microsoft.com/Demo#DemoSmartTag",
        "Test Smart Tag")
Dim simpleAction As Microsoft.Office.Tools.Word.Action =
    Globals.Factory.CreateAction("Test Action")

simpleSmartTag.Terms.Add("blue")
simpleSmartTag.Actions = New Microsoft.Office.Tools.Word.Action() { _
    simpleAction}
Me.VstoSmartTags.Add(simpleSmartTag)
Microsoft.Office.Tools.Word.SmartTag simpleSmartTag =
    Globals.Factory.CreateSmartTag(
    "www.microsoft.com/Demo#DemoSmartTag",
    "Test Smart Tag");
Microsoft.Office.Tools.Word.Action simpleAction =
    Globals.Factory.CreateAction("Test Action");

simpleSmartTag.Terms.Add("blue");
simpleSmartTag.Actions = new Microsoft.Office.Tools.Word.Action[] { 
    simpleAction };
this.VstoSmartTags.Add(simpleSmartTag);

.NET Framework 安全性

請參閱

參考

ApplicationFactory 介面

Microsoft.Office.Tools.Word 命名空間