Modifying a Word document without using Word Automation

  • Thread starter Michael G. Schneider
  • Start date
M

Michael G. Schneider

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
 
R

Richard K Bethell

Michael G. Schneider said:
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.
 
M

Michael G. Schneider

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
 
M

myLittleTools.net

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.
 
M

Michael G. Schneider

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
 
E

el.c. - myLittleTools.net

You can have a look at myLittleWriter
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
// (e-mail address removed)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top