Scripts.Add Method
Adds a Script object to the Scripts collection of one of the following objects: a Document or Range object in Microsoft Word; a Worksheet or Chart object in Microsoft Excel; or a Slide, SlideRange, slide Master, or title Master object in Microsoft PowerPoint. Returns a Script object.
Syntax
expression.Add(Anchor, Location, Language, Id, Extended, ScriptText)
expression Required. A variable that represents a Scripts object. The Scripts collection.
Parametersargument accepts an Excel Rangeobject, which specifies the placement of the script anchor on an Excel worksheet. You cannot insert script anchors into Excel charts.argument, the argument isn't used; the location of the argument determines the location of the script anchor.argument specifies an SGML identifier used for naming elements. Valid identifiers include any string that begins with a letter and is composed of alphanumeric characters; the string can also include the underscore character (_). The ID must be unique within the HTML document. This parameter is exported as the ID attribute in the SCRIPTtag.and parameters. The default is the empty string. Attributes are separated by spaces, the same as in HTML. The Microsoft Office host application doesn't provide any means of checking the syntax of passed attributes.
| Name | Required/Optional | Data Type | Description | |||
|---|---|---|---|---|---|---|
| Anchor | Optional | Range (Microsoft Excel only) | The | Anchor | ||
| Location | Optional | MsoScript | Specifies the location of the script anchor in a document. If you've specified the | Anchor | Location | Anchor |
| Language | Optional | MsoScript | Specifies the script language. | |||
| Id | Optional | String | The ID of the SCRIPT tag in HTML. The | Language | Language | |
| Extended | Optional | String | Specifies attributes that are to be added to the SCRIPT tag (LANGUAGE and ID attributes are exported through the | Language | Id | |
| ScriptText | Optional | String | Specifies the text contained in a block of script. The default is the empty string. The Microsoft Office host application doesn't check the syntax of the script. |
Remarks
A shape associated with a script block isn't exported or printed as a shape in HTML; only the script block gets exported. You cannot use the Add method to add a script anchor to a PowerPoint slide range that contains more than one slide.
Example
This example adds a new Script object to the specified range on worksheet one in the active workbook.
| Visual Basic for Applications |
|---|
|