How to script KWord/Openwriter to fill address lines in a letter?

I may miss the right terms to query Google, so perhaps you can help me. I want to write a script which starts/ensures whatever wordprocessor, creates a new document from a given $TEMPLATE, fills the address lines for a given $CONTACT, and sets the cursor right behind the “Dear Sir/Madam,”. $CONTACT may be the UID from KABC or just some already preformatted address string.

Is this possible with Openwriter or, better, KWord? Are there already similar examples?

Thanks, if only for the right query terms 🙂