Udostępnij za pośrednictwem


Bookmark.Scripts Property

Definition

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

public:
 property Microsoft::Office::Core::Scripts ^ Scripts { Microsoft::Office::Core::Scripts ^ get(); };
public Microsoft.Office.Core.Scripts Scripts { get; }
member this.Scripts : Microsoft.Office.Core.Scripts
Public ReadOnly Property Scripts As Scripts

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.

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

Applies to