Add Method (Scripts Collection)

         Example         Applies To

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. The Scripts collection.

Anchor    Optional Range (Microsoft Excel only). The Anchor argument accepts an Excel Range object, which specifies the placement of the script anchor on an Excel Worksheet. You cannot insert script anchors into Excel charts.

Location   Optional Long. Specifies the location of the script anchor in a document. Can be either of the following MsoScriptLocation constants: msoScriptLocationInBody or msoScriptLocationInHead. The default value is msoScriptLocationInBody. If you’ve specified the Anchor argument, the Location argument isn’t used; the location of the Anchor argument determines the location of the script anchor.

Language   Optional Long. Specifies the script language. Can be one of the following MsoScriptLanguage constants: msoScriptLanguageASP, msoScriptLanguageJava, msoScriptLanguageOther, or msoScriptLanguageVisualBasic. The default value (language) is msoScriptLanguageVisualBasic.

Id   Optional String. The ID of the <SCRIPT> tag in HTML. The Id 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 <SCRIPT> tag.

Extended   Optional String. Specifies attributes that are to be added to the <SCRIPT> tag (LANGUAGE and ID attributes are exported through the Language and Id parameters and should not be exported through the Extended parameter). 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.

ScriptText   Optional String. Specifies the text contained in a block of script. The default is the empty string. The 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.