Browse » Home
Friday, June 22, 2012
How to Add Scripts to Word Documents
1. Open Word and open the Script Editor. This is part of Office and included in Word. Open Script Editor in Office 2000 or 2003 by opening the 'Tools' menu, point to macros and select 'Script Editor.' If you are running Office 2007, click the 'Office' button and clicl 'Excel Options.' Go to the 'Popular' tab and select the 'Show Developer tab' in the ribbon.
2. Add script to the Word document. Do this by utilizing the Scripts collection's 'Add' method. This method uses elective arguments that can specify the script's ID attribute, language, location, additional tag attributes, and the script to contain itself within the '<SCRIPT>' tags. Using the 'Add' method automatically creates HTML tags around the script you wrote so that browsers that do not read script ignore it.
3. Use the 'Anchor' argument within the 'Add' method to identify where the 'Script' object should be put in the document. When scripting in Word, if a value is not specified for the 'Anchor' argument, the 'Script' object is inserted at the current location of the cursor.
4. Specify the 'Script' object to a 'Selection' object or an 'InLineShape' object. If you put a 'Selection' object in the 'Anchor' argument, the 'Script' object will be put at the end of the 'Selection' object. But if you specify an 'InLineShape' object in the 'Anchor' argument, the 'Script' object is placed before the marker of the paragraph so that the paragraph that is the anchor point is for the shape.