Automated "mail merge" of a single record database to Writer

Writing a book, Automating Document Production - Discuss your special needs here
Post Reply
deilenberger
Posts: 7
Joined: Tue Dec 04, 2007 8:43 pm
Location: Freehold NJ

Automated "mail merge" of a single record database to Writer

Post by deilenberger »

Folks,

I'm trying to move our organization from Word-97 to something a bit more modern... OpenOffice.

We have an in-house program that we use to create a mail-merge database in DBF format (the program actually does lots more - but this is what the question is about..)

It creates a single record DBF file in a standardized location on the users computer. It then opens word - with a form mail-merge letter (selected from within the in-house program) - that automatically merges the data from the single-record DBF file and allows the user to edit and/or print the form letter.

All of this happens automatically using MS Word-97 (and later versions.)

I can't figure out how to make this happen automatically (open the document and perform the merge) with Writer. I can open Writer, and I can open Writer with the selected document - but I can't figure out how to get Writer to automatically merge the single record into the document (something that is fairly trivial to do in Word..)

Any hints would be gratefully appreciated!

Don Eilenberger
Don Eilenberger
Bid-Service LLC
User avatar
foxcole
Volunteer
Posts: 1507
Joined: Mon Oct 08, 2007 1:31 am
Location: Minneapolis, Minnesota

Re: Automated "mail merge" of a single record database to Writer

Post by foxcole »

Hi, Don.

Your question is unfortunately very vague, and I can't tell what exactly it is you're asking. Are you aware that Writer has a mail merge function---is that what you're asking? Or have you looked into existing documentation and the mail merge feature but can't figure out how to do a merge that isn't a mailing label address? Or is your question about using the DBF database? If we start with what information you're looking for, it will be much easier to give you the right details. ;)
Cheers!
---Fox

OOo 3.2.0 Portable, Windows 7 Home Premium 64-bit
deilenberger
Posts: 7
Joined: Tue Dec 04, 2007 8:43 pm
Location: Freehold NJ

Re: Automated "mail merge" of a single record database to Writer

Post by deilenberger »

Fox, sorry..

Yes - I know about the mail-merge feature. And that's what I'm trying to use.

With MS-Word - if you open a document linked to a database file used for mail-merge, it opens the first record in the file and puts the data from this record into the open document.

I've used this feature to automate form letters our salesmen send to customers. I do that by creating a single-record database with the merge info in the record and opening Word with the mail-merged document(s).. all this is being called by a custom application written in Clarion/Soft-Velocity.

I tried doing this in Writer. I created a merge document. It appears Writer doesn't automatically fill in the merge data from the linked database. It requires manual (or macro driven) intervention to get it to do this (unless I've missed something.) I've written a macro that does this.. but it would require an extra step on the part of our salesmen - to open and run the macro. That's beyond their comprehension skillset - I've got to make it work like the Word version works.

Someone mentioned there is a way to have a macro open/run automatically on document opening.. can't find this in the documentation, perhaps a hint in the right direction?

Thanks!
Don Eilenberger
Bid-Service LLC
User avatar
foxcole
Volunteer
Posts: 1507
Joined: Mon Oct 08, 2007 1:31 am
Location: Minneapolis, Minnesota

Re: Automated "mail merge" of a single record database to Writer

Post by foxcole »

Oh---you posted two topics on this question. Please don't do that. :)

You can assign the macro to an event in Tools> Macros> Organize macros> OpenOffice.org Basic. Click the Assign button, select the Events tab and select the "Open document" event. Click the Macro button and navigate to the macro you created.

At the bottom of the Assign dialog, you may want to make sure the current document is selected (and that you stored the macro locally in the document) because you want this macro and assigned event to be local to the document. i'm assuming you'll create a template of the document, so these will always be available in the template.
Cheers!
---Fox

OOo 3.2.0 Portable, Windows 7 Home Premium 64-bit
deilenberger
Posts: 7
Joined: Tue Dec 04, 2007 8:43 pm
Location: Freehold NJ

Re: Automated "mail merge" of a single record database to Writer

Post by deilenberger »

Fox,

Thanks. I found that - and got the macro to run when the document is opened.. the only remaining problems:

- I can't get a macro to select the record in the datafile and then apply it by using the "Data to Fields" button. I've tried recording it numerous times, and it just doesn't seem to work.

- I'm also experincing a problem with it locking the datafile, and not removing the lock when Writer is closed. It doesn't do this every time - but when it does it requires a reboot of the system to release the lock (W2K, SP4).
User avatar
foxcole
Volunteer
Posts: 1507
Joined: Mon Oct 08, 2007 1:31 am
Location: Minneapolis, Minnesota

Re: Automated "mail merge" of a single record database to Writer

Post by foxcole »

[quote="deilenberger"]- I can't get a macro to select the record in the datafile and then apply it by using the "Data to Fields" button. I've tried recording it numerous times, and it just doesn't seem to work. [/auote]
The macro recorder doesn't capture everything you can do in Writer, unfortunately. Perhaps for this and the file-locking problem, you might want to ask in the Macros board:
http://user.services.openoffice.org/en/ ... m.php?f=20
Cheers!
---Fox

OOo 3.2.0 Portable, Windows 7 Home Premium 64-bit
Post Reply