Worksheet.Scripts Property (2007 System)

Gets the 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.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Scripts As Scripts
'Usage
Dim instance As Worksheet 
Dim value As Scripts 

value = instance.Scripts
[BrowsableAttribute(false)]
public Scripts Scripts { get; }
[BrowsableAttribute(false)]
public:
property Scripts^ Scripts {
    Scripts^ get ();
}
public function get Scripts () : Scripts

Property Value

Type: Scripts
The 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

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace