Bookmark.Scripts Property

Definition

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

C#
public Microsoft.Office.Core.Scripts Scripts { get; }

Property Value

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

Examples

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.

C#
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());
}

Applies to

Product Versions
Visual Studio Tools for Office 2017, 2019, 2022