Share via


Working with Scripts

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

You can use the Scripts collection and the Script object to programmatically access script, or insert script into a cell or range in an Excel worksheet, a PowerPoint slide, or a Word document or Word Selection object. In addition, if you use an Office application to open an HTML page, any script contained in that page will be available through the Scripts collection.

Note   Microsoft Access and Microsoft Outlook do not use this shared Office component. In Access, you can create an HTML page by using the DataAccessPage object, but you cannot use VBA to programmatically access script by using the Office script object model within Access. For more information about creating and manipulating Web pages in Access, see Chapter 5, "Working with Office Applications," and Chapter 12, "Using Web Technologies."

Every Script object that is inserted in an Office document includes a Shape object of the type msoScriptAnchor. In Excel and PowerPoint, these shapes are added to the Worksheet or Slide object's Shapes collection. In Word, these shapes are added to a document's InLineShapes collection.

If you want to write script in a document you create in an Office application, use the Microsoft Script Editor. On the other hand, if you want to add script to an Office document programmatically, from an add-in for example, use the objects, properties, and methods of the script object model discussed here. For more information about creating add-ins, see Chapter 11, "Add-ins, Templates, Wizards, and Libraries."