User Guide

224 Chapter 15 Scripting the Visual Tools Object Model
Writing and executing scripts
HomeSite+ for Dreamweaver MX exposes an Object Model, enabling developers to
manipulate program functionality from external applications. In addition, power
users can create scripts to automate tasks using JScript or VBScript and run the
scripts from HomeSite+ for Dreamweaver MX.
This internal scripting feature requires the Microsoft ActiveScripting engine version
3.1 or later, also known as Windows Script. The engine is not installed with
HomeSite+ for Dreamweaver MX. If you installed Microsoft Internet Explorer 4.0 or
later on your computer, then you have the correct ActiveScripting engine. Otherwise,
you must download it from http://www.microsoft.com/msdownload/vbscript/
scripting.asphttp://www.microsoft.com/msdownload/vbscript/scripting.asp/a.
Note
If you have trouble running an external Windows (*.ws) script, check if your
anti-virus software is blocking its execution. Anti-virus software should not affect
JScript or VBScript scripts that are run from within HomeSite+ for Dreamweaver MX.
The VTOM hierarchy
The object hierarchy is basic; the Application object is the parent of all the other
objects and none of the other objects is a parent.
The VTOM hierarchy can be illustrated as follows:
Application
ActiveDocument
DocumentCache
Project
ProjectManager
DeploymentManager
HTTPProvider
ZIPProvider
The simplicity of the object model makes syntax notation very straightforward. To
call a property or method, begin at the object root, append the child object name (if
any), the property or method name, separated by a period, and then the parameters.
For example,
Application.ActiveDocument.SaveAs(CurrentFolder + '\\' + sFile);
Writing a script
For a script to be executable from within HomeSite+ for Dreamweaver MX, it must
contain a Main routine. In JScript, create a function Main; in VBScript, create a Sub
Main routine. Without this routine, the script fails.