WorksheetBase.Scripts Property
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.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)
Syntax
'Declaration
Public ReadOnly Property Scripts As Scripts
public Scripts Scripts { get; }
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"],
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.