Printing documents through word

This is a discussion on Printing documents through word within the Windows Programming forums, part of the Platform Specific Boards category; I have a program which connects to a database for a company, and it needs to be able to print ...

Printing documents through word

I have a program which connects to a database for a company, and it needs to be able to print invoices etc. I would like to be able to design the template for the invoices and other documents it will produce in MS word, and have the program add the data from the database to the document, and then print it. I've seen programs that use word in this way before, and it might also allow the user to modify the template easily themselves without inventing my own word processor. It doesnt have to be word, but if not it needs to be free software to distribute with my app.

The alternative is designing all my documents using GDI code, which would be very time consuming and impossible to edit by the user.

Any advice or other alternatives are appreciated.

ps Sorry for posting twice, I accidentally put my first post on the c++ board, so I've had to repost it here.

Yeah thanks fordy. I assume that's using automation, been reading about that in my biig MFC book last night. Did you have to use VB for the whole app or just the automation client part, because I'm already half way in C++ and I dont want to have to remake the program. If you could post some code that'd be great.

I've started reading up on automation in C/C++ using MFC, although I've found some documentation on doing it in VB too, but I'm still not clear whether I can include VB code for the automation client part of my program and C++ for the rest, and still access all of my C++ variables and/or recordsets. I'd like to use VB if possible, the code for automation seems a lot easier and shorter, although I've no experience in it. If anyone knows anything about mixing languages in this way I'd be glad to hear it, I'm using VS.NET too if that helps

By the way Fordy have you got that code handy? Sorry to push but I'm on a tight deadline, just wanted to know whether to wait for your code and work on something else (there's plenty to do) or start learning and writing this myself.