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 πŸ™‚


5 thoughts on “How to script KWord/Openwriter to fill address lines in a letter?

  1. For look into the developer book. is controllable remotely via the UNO component API in the language of your choice: java, C++, python, rexx, basic …

    I don’t however not know if the same is possible with KWord. It might be possible with KWord+DCOP. Let me know if you find something!


  2. Save your template use as variables e.g
    @first_name@, @last_name@, @place@, etc

    The script may look like:
    # cp template.odt letter.odt
    # unzip -p letter.odt content.xml > content.xml
    # sed -i ‘s/@variables@/value/g’ content.xml
    # zip letter.odt content.xml
    # kword letter.odt

    This works quite nice!

  3. Thanks for your comments.

    @RB: Hm, nice idea πŸ™‚ My problem with it is that it won’t work so easily when “value” has linefeeds in it, like with multiline addresses (KABC has a nice call “formattedAddress()”).

    @jstaniek: kexi2odt.exe looks similar to what I want. But then all I want to do is to fill some variables/field, using the editor that has already opened it. Using another, third program that can parse and edit odt files only blows things up IMHO.

    Meanwhile I found that using the DCOP call “setCustomVariableValue(String,String)” might get me close to my target, if only limiting me to KWord. But hey, OOo users are free to send something that only works with OOwriter.

    Looks like I found a way to go which is sufficient for prototyping…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.