Edit document from VB 6 without Microsoft Word

Hi all,
I am currently writing a program which essentially reads from and writes to a .mdb database, and then based on some options. Selects the appropriate .doc file and the appropriate record from the .mdb and uses the MS Word control to open the doc in word, find and replace place holder values with the data from the database then print and close the document.
This is all working fine, my problem is that now I'm going to need to install and run this program on systems that dont have Word installed. Is there any way I can do a simmilar thing without needing Word? I'd prefer to keep the documents as .doc but its not essential.
I've already changed th program from using Access to read/write the database to using the Microsoft ActiveX Data Objects 2.0 Library so I wouldn't need Access installed.
Maybe there is something simmilar for Word?

Thanks for any advice.
Who is Participating?
Mark_FreeSoftwareConnect With a Mentor Commented:

think i deserve points with my comment from 05/19/2006 08:01AM CEST

the other comments are "follow-up" comments, to explain some more questions related to this Q

as far as i know it is not possible

you can however convert these documents to rich text,
and open them with a richtextbox
Nemesis09Author Commented:
Thanks for the idea, but when I tried it the documents are missing parts and are out of allignment when they are opened in a richtextbox, although the .rtf's are fine when opened with word.
Plus, how can I Find/Replace, or other wise insert text in specific areas with specific formatting using this method?
Thanks for any further info.
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.


if you add e secondare textbox on your form, with multiline set to true,
you can use this code to display the formatting:

text1.text = Richtextbox1.rtftext

and then alter the text in text1

to save it back to the richtextbox use this one:

Richtextbox1.rtftext = text1.text

(ofcourse you don't kneed a textbox to replace programmatically, but then you can see the contents of the richtextbox and how it is formatted)
Nemesis09Author Commented:
Why does it display differently in a text box vs a richtext box? And I still have the same problem of inserting the text.
The idea is that the program gets the data (from a combination of textboxes and a .mdb database) then inserts it (now stored each in its own variable) in to the document, prints the document, and closes it without saving.
Thanks for your help so far.

if this is the only things you are going to use that document for, you can paste some special text where you want the data (like #$1$#)

and then you can do a replace$(yourstringhere,"#$1$#",yourdatahere)
Nemesis09Author Commented:
...hmm now I think were getting somewhere...
So if I open the .rtf in "richtextbox1"
Then use something like;
        " replace$(richtextbox1.rtftext, "RegNo", "ABC-123") "
It will replace "RegNo" with "ABC-123" in the rich textbox... yes?... excelent :)
And as you say, the user never needs to see any of this, just enter some data in several textboxes then have it inserted and printed in a formatted document. The first time they see the actual ".rtf" is the hardcopy on paper.

So just  one more thing... How do I print it?

Thanks for all your help, and sorry for my often slow replies, this is definatley worth more than 125 points... I'll have to fix that :)

you can print trough the "printer" object in vb

this is the default printer.

to test it, i would suggest u download some pdf printer (cute pdf is really good)
and install it as the default printer
that way you can print to pdf files to test the formatting.

the pdf printer will behave exactly the same as a normal printer, except the fact that it gives a dialog to save the pdf,
and it costs no paper.

for more info on the printer object:
Nemesis09Author Commented:
I'm sorry I haven't  accepted an answer to this question as yet. I agree that you (Mark_FreeSoftware) deserve the points for your outstanding help on this topic, your assistance has been unbelieveably helpful and your quick responses was greatley appriciated.

The reason I had not "accepted" your answer is that I thought you deserved a lot more points than the question was acctually for, so, the plan was not to accept an answer for a while, let my points build up, then give you an amount indicitive of how much this question got me out of a sticky situation. (say maybe 500 points).

The problem was that other urgent matters came up which demanded my EE points, plus I was out of the country and didn't have access to a pc for a while.

Reguardless, I'll give you all the points I have at the moment. Once again I'm sorry I dont have enough to give you the 500 points you deserve.

Thanks again for all your terrific help.

>>I'll give you all the points I have at the moment.

to know you did that, is showing much better you appreciate it, than someone with enough points giving away 500 points!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.