VB-to-Word data sending.
Posted on 1998-11-24
I need to learn how to send data from VB databases to a Word document.
The exact way I want to make it is: I navigate a VB database, I find the exact data (i.e. a person and the associated address and birth date), and I press a CommandButton "Send".
Then I want to open a pre-existing Word document (I know the exact document and its path) to insert the data. Some data will be in the middle of a phrase, and has to be at an exact place, as it will print to a pre-printed form.
Have I to put in the Word doc "marks" at the exact places to substitute them with the data? How is it made overstriking? (If I insert, the rest of the document will be displaced, I think, and I don't want it to move).
I need a little code sample, not hints. It would be enough if you tell me how to connect to Word ("Word.Application", Word.Document", both?), how to send a text from a variable or a field, how to insert this text at a specific location without displacing the rest, and how to print the document directly from VB without having to go to Word's File:Print.
A final little collateral question: If I wanted to reformat the whole document after inserting data (i.e. a personalized mailing with the name in the middle of the phrase) to re-justify it, how it would be made?
I own VB 5 Enterprise and Office 97 Pro, and I know VB for Applications is the common gateway between them.
Thank you in advance, and greetings from Spain, Europe.