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)

Syntax

'Declaration
ReadOnly Property Scripts As Scripts
Scripts Scripts { get; }

Property Value

Type: Microsoft.Office.Core.Scripts
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.

Private Sub BookmarkScripts()
    Dim scriptRange As Word.Range = Paragraphs(1).Range
    Dim myScript As Office.Script = Me.Scripts.Add( _
        scriptRange, Microsoft.Office.Core.MsoScriptLocation _
        .msoScriptLocationInBody, Microsoft.Office.Core _
        .MsoScriptLanguage.msoScriptLanguageVisualBasic, _
        "Script ID", "Extended", "Script Text")

    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")

    MessageBox.Show("Number of scripts in bookmark1: " & _
        Bookmark1.Scripts.Count.ToString)

End Sub
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());
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace