1 Reply Latest reply on Aug 5, 2008 6:30 AM by darbus23

    can you amend Word docs using CF?

    happysailingdude Level 1
      hi there,

      i have a load of word documents (.doc / docx) on my server

      i want to do the following:

      1 read each document to find any instances of an email address contained within (will use Regex for that i guess)
      2 replace each email address with "---there was an email address here and the server has removed it---"
      3 save the new (amended) word document

      Does CF 8 have any new clevernesses to help me out here?

      I suspect I may have to read the contents of the word doc into memory, make my changes there and then create a new word doc (using cfdocument?) with my amended content that is now in memory.

      If anyone has any comments / suggestions to help me avoid any dead-ends i'd be ever so grateful.

      Thanks very much indeed.
        • 1. Re: can you amend Word docs using CF?
          If you have MS Office installed on the server then you could use the filesystem object and COM to manipulate the files.

          If you don't have that installed then you could possibly look into using Apache's POI-HWPF(just google apache+poi+hwpf). I recently used it to extract the text from a Word document but I'm not sure about it's Word document creation/save as functionality.

          Check out this post if you decide to go the POI route because CF 8 comes with a preinstalled version of POI 2.5 that does not include the HWPF classes.