Modifying a Word document without using Word Automation

Discussion in 'ASP General' started by Michael G. Schneider, Dec 15, 2003.

  1. I know that using Word Automation inside an ASP page is no good idea.

    Anything I want to do in the current project is: open document, change some
    text, save and close document. Basically changing some variables, consting
    of a name embraced by special chars, to some value. As for example: change
    "[FirstName]" to "Michael".

    Does anybody know whether there is a way for achieving this with basic "file
    input / output". Can I regard a Word document as some binary data, perform
    the replacement, and save the data, without destroying Word's internal
    structure?

    Michael G. Schneider
     
    Michael G. Schneider, Dec 15, 2003
    #1
    1. Advertising

  2. "Michael G. Schneider" <> wrote in message
    news:%...
    > I know that using Word Automation inside an ASP page is no good idea.
    >
    > Anything I want to do in the current project is: open document, change

    some
    > text, save and close document. Basically changing some variables, consting
    > of a name embraced by special chars, to some value. As for example: change
    > "[FirstName]" to "Michael".
    >
    > Does anybody know whether there is a way for achieving this with basic

    "file
    > input / output". Can I regard a Word document as some binary data, perform
    > the replacement, and save the data, without destroying Word's internal
    > structure?


    Not the binary version of the Word file. However, if you use RTF files, they
    are parseable text. RTF supports most of Word's features, and can nearly
    fully contain its formats. You'd be well advised to use RTF files in the
    workflow you are considering. The binary DOC file format is unpublished,
    you'd have no way of figuring out how to modify it without some serious
    reverse engineering skills.

    R.
     
    Richard K Bethell, Dec 15, 2003
    #2
    1. Advertising

  3. "Richard K Bethell" <> schrieb im Newsbeitrag
    news:...

    > Not the binary version of the Word file. However, if you use RTF files,
    > they are parseable text. RTF supports most of Word's features, and
    > can nearly fully contain its formats. You'd be well advised to use RTF
    > files in the workflow you are considering. The binary DOC file format
    > is unpublished, you'd have no way of figuring out how to modify it without
    > some serious reverse engineering skills.


    Thank's a lot for the answer.

    In a former project I used RTF files for this purpose. Besides not
    supporting Word's complete feature set, they had one disadvantage:

    I did not find an ActiveX DLL for reading / writing RTF files. So I did the
    IO myself. As I did not want to write a full RTF parser, I simply tried to
    find my variables inside the RTF stream. However, there were situations,
    where a variable name was cut into pieces by matching curly braces. So if
    the variable name was "[XYZ]" inside the Word document, inside the RTF a
    "[X}{YZ]" could be found.

    Michael G. Schneider
     
    Michael G. Schneider, Dec 15, 2003
    #3
  4. > I did not find an ActiveX DLL for reading / writing RTF files. So I did the
    > IO myself. As I did not want to write a full RTF parser, I simply tried to
    > find my variables inside the RTF stream. However, there were situations,
    > where a variable name was cut into pieces by matching curly braces. So if
    > the variable name was "[XYZ]" inside the Word document, inside the RTF a
    > "[X}{YZ]" could be found.



    You can have a look at myLittleWriter
    (http://www.myLittleTools.net/mlw. This is windows script component
    which allows to generate RTF files on the fly. It may help you...

    Best regards
    el.c.
     
    myLittleTools.net, Dec 16, 2003
    #4
  5. "myLittleTools.net" <> schrieb im Newsbeitrag
    news:...

    > You can have a look at myLittleWriter
    > (http://www.myLittleTools.net/mlw. This is windows script component
    > which allows to generate RTF files on the fly. It may help you...


    Will the tool allow me to read an existing RTF, then run through the text,
    perform some replacements, and then save the RTF? Or must the code create
    the RTF from scratch?

    Michael G. Schneider
     
    Michael G. Schneider, Dec 16, 2003
    #5
  6. >> You can have a look at myLittleWriter
    >> (http://www.myLittleTools.net/mlw. This is windows script component
    >> which allows to generate RTF files on the fly. It may help you...


    > Will the tool allow me to read an existing RTF, then run through the
    > text, perform some replacements, and then save the RTF? Or must the
    > code create the RTF from scratch?



    myLittleWriter is a "writer" and does not allow to read existing RTF
    files. You should then create the RTF file from "scratch".

    Best regards
    el.c.

    P.S. : sorry for the email in your own box... i clicked the wrong button

    // myLittleTools.net : leading provider of web-based applications.
    // myLittleAdmin : online MS SQL manager
    // http://www.mylittletools.net
    //
     
    el.c. - myLittleTools.net, Dec 16, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=
    Replies:
    0
    Views:
    427
    =?Utf-8?B?Sm9l?=
    Nov 15, 2004
  2. Replies:
    2
    Views:
    667
  3. srk
    Replies:
    0
    Views:
    667
  4. srk
    Replies:
    0
    Views:
    630
  5. apondu
    Replies:
    0
    Views:
    610
    apondu
    Jul 19, 2007
Loading...

Share This Page