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 a Microsoft® Excel worksheet, a Microsoft® PowerPoint® slide, or a Microsoft® Word document or Word Selection object. In addition, if you use a Microsoft® Office application to open an HTML page, any script contained in that page will be available through the Scripts collection.
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.
In This Section
- Understanding Script Object Properties
Learn how to access Script objects and add them to documents. - Adding and Removing Script from a Document
Add script to and remove script from a document by using the Scripts collection's Add and Delete methods.
Related Sections
- Working with Shared Office Components
Search for files, use the Office Assistant, manipulate command bars, read and write document properties, read and write script, and hook add-ins to your Microsoft® Office application using a set of shared objects available in all Office applications. - Referencing Shared Office Components
Return a reference to a shared component object by using the appropriate properties. - Working with the FileSearch Object
Programmatically access the functionality of the Office File Open dialog box. - Working with the Office Assistant
Use the objects, methods, and properties of the Office Assistant object to programmatically control the Office Assistant. - Working with Command Bars
Write code to manipulate command bars that can be used in any Microsoft® Office application or custom application you develop. - Working with Document Properties
Use document properties to create, maintain, and track information about a Microsoft® Office document.