i want to know how to create a word document because i have a project the instructor gave us a project so we have to create a word document but i have no idea how to create therefore i'm asking for some help please
| This example shows how to create a Word document, using "Hello World". |
<!--- 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>
|
| For more tutorials on how to use ColdFusion to interact with COM objects, visit: http://www.cfcomet.com |
i want to know how to create a word document because i have a project the instructor gave us a project so we have to create a word document but i have no idea how to create therefore i'm asking for some help please
So here's the code - what do I do with it? Where do I start? Do I need additional components? Is there an example anywhere? Thanks
the com, is it used on server side, so you need word on the server..??