Expand Minimize

Bookmark.Scripts Property

Gets a Scripts collection that represents the collection of HTML scripts in the Bookmark control.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Scripts Scripts { get; }

Property Value

Type: Microsoft.Office.Core.Scripts
A Scripts collection that represents the collection of HTML scripts in the Bookmark control.

The following code example adds a Script to the first paragraph, and then adds a Bookmark control to the first paragraph. The code then displays the number of scripts the bookmark contains in a message box.

This example is for a document-level customization.

private void BookmarkScripts()
{
    Word.Range scriptRange = Paragraphs[1].Range;
    Office.Script myScript = this.Scripts.Add(scriptRange, Microsoft.Office.Core.MsoScriptLocation.msoScriptLocationInBody,
        Microsoft.Office.Core.MsoScriptLanguage.msoScriptLanguageVisualBasic, "Script ID", "Extended", "Script Text");

    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(Paragraphs[1].Range, "bookmark1");
    MessageBox.Show("Number of scripts in bookmark1: " +
        bookmark1.Scripts.Count.ToString());
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft