none
Speed up mailmerge RRS feed

  • Question

  • Hi All

    I’ve developed some VBA routines loading data from SQL Server and execute a mail merge. The template containing the VBA codes gets called from another executable (C++). That code has been written for a Word 2000 template. I’m migrating that code to Word 2013 and have a major speed issue where I need your help.

    For the Word 2000 solution I’ve already applied some VBA optimization code when I coded it years back:

    «… Entry point VBA function …»
    ActiveWindow.ActivePane.View.Type = wdNormalView
    Application.ScreenUpdating = False
    Options.Pagination = False
    «... prepare mail merge …»
    ActiveDocument.MailMerge.Execute True
    «… rollback the ScreenUpdating, Pagination options …»

    I even loaded the data into an RFT file on the local computer and used that document as a source for MailMerge, that was a big booster.

    When I execute that code with Word 2000 it takes about 6 seconds to load 50 records into the RTF and have the MailMerge executed on that RTF as a datasource. Each document is one page long. I can use the same VBA code in Word 2013. If I execute the MailMerge with the same 50 records it takes 72 seconds until the mail merge is done.

    The big part of time used is during the command «ActiveDocument.MailMerge.Execute»: 65 seconds. The Word application is frozen with a black frame during that time so there is no GUI activity during the Mail Merge.

    Does anybody have an idea on how to speed up the process and getting the values out of Word 2013 on what I’ve achieved with Word 2000?

    Thanks for any help
    Martin


    Monday, September 9, 2013 4:33 PM

Answers

  • Hi Martin

    Since release of Office 2007, and with each version, code execution has generally gotten slower. In part, this may be a result of the new file formats. And security issues may also play a role - I've never really seen a "this is why" answer from MS on the topic.

    If speed is an issue, don't automate the Word application. Generate the documents "from scratch" based on the Open Office XML file formats introduced with Office 2007. C++ can certainly do this, as can C# and VB.NET, also using the Open XML SDK.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by Martin Koenig Monday, September 9, 2013 7:03 PM
    Monday, September 9, 2013 5:56 PM
    Moderator

All replies

  • Hi Martin

    Since release of Office 2007, and with each version, code execution has generally gotten slower. In part, this may be a result of the new file formats. And security issues may also play a role - I've never really seen a "this is why" answer from MS on the topic.

    If speed is an issue, don't automate the Word application. Generate the documents "from scratch" based on the Open Office XML file formats introduced with Office 2007. C++ can certainly do this, as can C# and VB.NET, also using the Open XML SDK.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by Martin Koenig Monday, September 9, 2013 7:03 PM
    Monday, September 9, 2013 5:56 PM
    Moderator
  • Hi Cindy

    Very unfortunate. Would you be able to point me to a good web site with helpfull tutorials about C++ and Open XML SDK since I'm new to this SDK?

    Thanks a lot

    Martin

    Monday, September 9, 2013 7:04 PM
  • Hi Martin

    C++ can't use the Open XML SDK, only C# and VB.NET.

    But C++ should certainly be able to manipulate the Zip package and XML files in the package (the SDK just makes it "easier"). Your starting point is OpenXMLDeveloper.org


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, September 10, 2013 9:23 AM
    Moderator