OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

MailMerge macro >10000 adresses, anybody ever did that?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Hark
General User
General User


Joined: 01 Sep 2005
Posts: 29

PostPosted: Mon Aug 28, 2006 6:18 am    Post subject: MailMerge macro >10000 adresses, anybody ever did that? Reply with quote

I want to create a simple MailMerge macro that writes merged .odt files. I thought I had finished it, it worked like a charm. But when I started to use it for bigger amounts of addresses it becomes slower and slower. It starts fast, but becomes slower as it comes lower in the address list. At the start it merges 66 documents each minute. After 2500 documents this has dropped to 42 documents/minute. My macro must be able to handle tens of thousands of documents, it is far too slow for that. If the macro will be able to keep a constant rate of 66 documents a minute that would be great.

Does anybody have some experience with such a macro?

This is the relevant part of my macro:

Code:
...
  sDocFile = "file://PATH/letter.odt"
  sOutFile = "file://PATH/"
  oConnection = oDataSource.getConnection("","")
...
 ' Do the mail merge
  oMerge = createUnoService("com.sun.star.text.MailMerge")
  oMerge.DataSourceName = "data_1"
  oMerge.ActiveConnection = oConnection
  oMerge.DocumentURL = sDocFile
  oMerge.CommandType = com.sun.star.sdb.CommandType.TABLE
  oMerge.Command = gSheetName
  ' Write to files instead of printer
  oMerge.OutputType = com.sun.star.text.MailMergeType.FILE
  oMerge.OutputURL = sOutFile

  oMerge.Execute(w)

  ' Remove data source
  oDataSourceContext.revokeObject("data_1")


I use OpenOffice.org 2.0.2 on a Debian stable box.
Back to top
View user's profile Send private message
AndrewZ
Moderator
Moderator


Joined: 21 Jun 2004
Posts: 4140
Location: Colorado, USA

PostPosted: Mon Aug 28, 2006 7:43 am    Post subject: Reply with quote

You may be experiencing a known bug:

http://qa.openoffice.org/issues/show_bug.cgi?id=66614
http://qa.openoffice.org/issues/show_bug.cgi?id=40827
http://qa.openoffice.org/issues/show_bug.cgi?id=54531
Back to top
View user's profile Send private message Visit poster's website
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 8984
Location: Lexinton, Kentucky, USA

PostPosted: Mon Aug 28, 2006 7:49 am    Post subject: Reply with quote

You might try this one but I don't know if it will handle a hugh number of records.

You basically tell the macro how many records you have and it uses copy and paste to creates a document with sufficient fields and a normal manual merge is then preformed.

Memory issues?

http://www.oooforum.org/forum/viewtopic.phtml?t=29291&highlight=mail+merge
Back to top
View user's profile Send private message
AndrewZ
Moderator
Moderator


Joined: 21 Jun 2004
Posts: 4140
Location: Colorado, USA

PostPosted: Mon Aug 28, 2006 8:00 am    Post subject: Reply with quote

If I remember correctly, there was a horrible bug that consumed about 200k per mail merge page, but that bug was resolved in or before OOo version 2.0.2. Nevertheless, it would be good to check the process's memory usage.

Also, version 2.0.4 is coming out very soon, and it might be worth to try a preview. On the other hand, the issue pages referenced in my previous message show that those specific issues are not fixed in 2.0.4.
http://download.openoffice.org/680/index.html
Back to top
View user's profile Send private message Visit poster's website
Hark
General User
General User


Joined: 01 Sep 2005
Posts: 29

PostPosted: Mon Aug 28, 2006 11:18 pm    Post subject: Reply with quote

Thanks for your answers. The bug reports don't really describe my problem. They are about the general slowness of the MailMerge Wizard. My problem is that the macro mailmerge functionality is not only slow, but becomes slower and slower when merging lots of documents. I can file a bug report, but I'd like to know for sure that my macro is not the problem here. Can anybody confirm that?
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1414
Location: France

PostPosted: Tue Aug 29, 2006 1:42 am    Post subject: Reply with quote

Hark wrote:
I can file a bug report, but I'd like to know for sure that my macro is not the problem here. Can anybody confirm that?

I assume there is no outside loop repeating this code many times.
Apparently you have just created a datasource only for the purpose of the mailmerge because you revoke it just after.

It seems from the name of your command, that your database is a Calc document. If this is the case, you should instead use a real database.

Then you open a connection and assign it to the mailmerge. IMHO this is not necessary, it is done by the mailmerge service. So these instructions could be suppressed:
Code:
  oConnection = oDataSource.getConnection("","")
  oMerge.ActiveConnection = oConnection

Hope this helps.
Back to top
View user's profile Send private message Visit poster's website
Hark
General User
General User


Joined: 01 Sep 2005
Posts: 29

PostPosted: Tue Aug 29, 2006 2:14 am    Post subject: Reply with quote

B Marcelly wrote:

Apparently you have just created a datasource only for the purpose of the mailmerge because you revoke it just after.

It seems from the name of your command, that your database is a Calc document. If this is the case, you should instead use a real database.


You are right, I use a Calc file as datasource. Should it be faster when I use a 'real' database? I will try to find out how to convert a Calc file to a database then.

B Marcelly wrote:

Then you open a connection and assign it to the mailmerge. IMHO this is not necessary, it is done by the mailmerge service. So these instructions could be suppressed:
Code:
  oConnection = oDataSource.getConnection("","")
  oMerge.ActiveConnection = oConnection

Hope this helps.


You are right, I have deleted oMerge.ActiveConnection = oConnection and that works. (I can't remove oConnection yet because I need it for something else, but that's not important here). However, this doesn't change the speed of the merge of course.
Back to top
View user's profile Send private message
Hark
General User
General User


Joined: 01 Sep 2005
Posts: 29

PostPosted: Fri Sep 22, 2006 12:50 am    Post subject: Reply with quote

I know a lot more about the slow mail merge now. The problem is very different from what I expected. The data connection is not the problem at all, it's the showing of the 'preview' for each element. If you are interested, I opened a new topic here:

http://www.oooforum.org/forum/viewtopic.phtml?p=174936
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group