Well, the code is right straight off the CFCOMET site with the path to my
file substituted.

Dave

======================================

<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 --->
        <CFTRY>
            <CFOBJECT
                ACTION="CREATE"
                CLASS="Word.Application"
                NAME="objWord"
                TYPE="COM">
          <!--- Word isn't installed, or ColdFusion doesn't have access to
it --->
          <CFCATCH TYPE="Object">
              <FONT COLOR="RED">Cannot create Word Object<BR>
              Make sure Word is installed and that ColdFusion has
permissions to
              use the Word COM objects.</FONT>
              <CFABORT>
          </CFCATCH>
        </CFTRY>
  </CFCATCH>
</CFTRY>

The following code will open an HTML file and convert it to a Word document.
You can use the "SaveAs()"
method of the "Documents" collection to convert the HTML file to various
other formats as well -- HTML
is only one of the options.

<CFSCRIPT>
    // HTML file path
    HTMLFilePath = "c:\www\ou\cgi-cf\adminsys\alumni\thecost.html";

    // Destination path for new Word document
    // We leave off the extension since we'll declare the file type later on
    WordFilePath = "c:\www\ou\cgi-cf\adminsys\alumni\";

    // Open Word in the background
    objWord.Visible = false;

    // Disable alerts such as: 'Save this document?'
    objWord.DisplayAlerts = false;

    // Get the 'Documents' collection
    objDoc = objWord.Documents;

    // Open the HTML document
    newDoc = objDoc.open(HTMLFilePath);

    /* Save it as a new Word document -- the extension will automatically
       be appended based on the file type we choose.
       Some of the file types to convert to:
       1 = .dot
       2 = .txt
       6 = .rtf
       9 = .asc
      10 = .ans
      11 = .doc
    */
    newDoc.SaveAs(WordFilePath,Val(6));

    // The next line would convert it to RTF instead
    // newDoc.SaveAs(WordFilePath,Val(6));

    // Close the document
    newDoc.Close();

    // Quit Word
    objWord.Quit();
</CFSCRIPT>







----- Original Message -----
From: "Mike Townend" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, November 15, 2001 11:25 AM
Subject: RE: WORD


> Need to see a little more of the code to work out where the error is
> coming from...
>
> -----Original Message-----
> From: Dave Hannum [mailto:[EMAIL PROTECTED]]
> Sent: 15 November 2001 15:45
> To: CF-Talk
> Subject: Re: WORD
>
>
> In trying the example from CFComet, I get an error.  What does this
> mean?
>
> ============================
> Value out of range
> The error occurred while processing an element with a general identifier
> of (CFSCRIPT), occupying document position (31:1) to (31:10).
>
> =============================
>
> Line starts the CFSCRIPT.
>
> Thanks,
> Dave
>
>
>
> ----- Original Message -----
> From: "Mike Townend" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Wednesday, November 14, 2001 2:46 PM
> Subject: RE: WORD
>
>
> > For how to use word... Install word and the VBA help information and
> > check msdn.microsoft.com as between them they should list all the
> > commands/functions that you can access with Word
> >
> > HTH
> >
> >
> >
> > -----Original Message-----
> > From: Adrian Cesana [mailto:[EMAIL PROTECTED]]
> > Sent: 14 November 2001 19:34
> > To: CF-Talk
> > Subject: WORD
> >
> >
> > Ive been checking out the WORD info at cfcomet.com, pretty cool stuff,
>
> > I have a few questions.
> >
> > 1) Where can I find examples of additional functionality, such as
> > using different fonts,bold,underline etc., replacing text and or just
> > general formatting options.  Inserting an image would be nice as well.
>
> > I have a template, I just need to modify the Address and a From Name.
>
> > I guess I could build the entire DOC per request.
> >
> > 2) Are there any security concerns with having WORD2K on my server?
> >
> > Thanks,Adrian
> >
> >
> >
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to