Udostępnij za pośrednictwem


WorksheetBase.Scripts Property

Gets the Microsoft.Office.Core.Scripts collection, which contains Script objects representing blocks of script or code in the worksheet when it is saved as a Web page.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

'Declaration
Public ReadOnly Property Scripts As Scripts
    Get
public Scripts Scripts { get; }

Property Value

Type: Microsoft.Office.Core.Scripts
The Microsoft.Office.Core.Scripts collection, which contains Script objects representing blocks of script or code in the worksheet when it is saved as a Web page.

Examples

The following code example uses the Scripts property to display the number of scripts in the current worksheet, add a script to the worksheet, and then display the updated number of scripts.

This example is for a document-level customization.

Private Sub AddScript()
    MsgBox("There are " & Me.Scripts.Count & " scripts in this worksheet.")

    Me.Scripts.Add(Me.Range("A1"), _
        Office.MsoScriptLocation.msoScriptLocationInBody, _
        Office.MsoScriptLanguage.msoScriptLanguageVisualBasic, _
        "ScriptOne", String.Empty, "MsgBox ""This is ScriptOne.""")

    MsgBox("There are " & Me.Scripts.Count & " scripts in this worksheet.")
End Sub
private void AddScript()
{
    MessageBox.Show("There are " + this.Scripts.Count +
        " scripts in this worksheet.");

    this.Scripts.Add(this.Range["A1", missing],
        Office.MsoScriptLocation.msoScriptLocationInBody,
        Office.MsoScriptLanguage.msoScriptLanguageVisualBasic,
        "ScriptOne", String.Empty, @"MsgBox ""This is ScriptOne.""");

    MessageBox.Show("There are " + this.Scripts.Count +
        " scripts in this worksheet.");
}

.NET Framework Security

See Also

Reference

WorksheetBase Class

Microsoft.Office.Tools.Excel Namespace