Well, I've tried both approaches. From my experience using Word 97,
using the CreateObject("Word.Application") is by far the best way to
go. You can lift large portions of code from Word just by running the
macro recorder to find out how to format particular text. It took me
about 2 to 3 hours to generate documents with headings with variable
spacing before and after them, indented paragraphs, bullet lists,
headers and footers etc. By contrast, going the RTF route is a real
nightmare, particularly if you use Word 97 to generate the RTF as a
model -- verbose is one word that springs to mind. To generate the
same documents reliably by writing the RTF directly took me several
days (and would likely take several days more if I wanted differently
formatted documents). For simple formatting, compare RTF from Word 97
and that for the same document from something like WordPad. It's a
revelation. If you must use Word to access some particular
functionality, use the earliest version available.
Writing out a text file, and reading it into a template you've created
(as was suggested earlier in this thread) sounds far too much like
hard work to me, and of course, if your users delete the template,
you're in deep trouble...
Of course, producing documents that look good, whether via RTF or by
directly creating them, does depend on having some skill at document
layout and formatting, but that's a rather different topic.
Quote:
>>> I have a question about creating word-files from a VB-application. The
>>> .txt file that we know how to generate from VB looks terrible. The
>>> application data will be taken into word and processed here. My question
>>> is of course what is the best way to do this. ...................
>There is a simple way to do this:
>Create a Document in WORD and create all the Paragraph-Formats you need.
>Create one Paragraph with each format and insert here a text like "Paragraph
>1"..."Par 3"...
>Save the Document as .RTF - File
>Now open this .RTF-File with some pure text editor.
>All you need is the preamble WORD creates for you.
>Then you can insert all the variable text using the paragraph-preambles (you
>have some examples in your file - all those "Paragraph 1"...
>then put the End-sequence into the new file and voila - thats it.
>best regards
>-------------------------------
>Rainer Pietsch
>-------------------------------
--
Dr Tony Gillie
IT Consultancy, Programming, and Desktop Publishing Services
PGP Key ID 54B4E689, Fingerprint E61CA9B811188727 4AFC4B12B7E00B4B