<!--- Try to connect to the Word application object --->
<CFTRY>
<!--- If it exists, connect to it --->
<CFOBJECT
ACTION="CONNECT"
CLASS="Word.Application"
NAME="objWord"
TYPE="COM">
<CFCATCH>
<!--- The object doesn't exist, so create it --->
<CFOBJECT
ACTION="CREATE"
CLASS="Word.Application"
NAME="objWord"
TYPE="COM">
</CFCATCH>
</CFTRY>
<CFSCRIPT>
/* This will open Word if running locally */
objWord.Visible = true;
/* This returns the 'Documents' collection the Word Object */
objDoc = objWord.Documents;
/* Create a new document */
newDoc = objDoc.Add();
/* Save the document to a location */
newDoc.SaveAs("D:\template_new.doc");
/* We specify the range of '0' -- start at the beginning of the document */
docRange = newDoc.Range(0);
/* Add text to the range */
docRange.Text = "Hello World!";
/* Save the changes */
newDoc.Save();
/* Close the document */
newDoc.Close();
/* Quit Word */
objWord.Quit();
</CFSCRIPT>