none
Word VBA running super slow RRS feed

  • Question

  • Since the very first version of Word with VBA (Word 97), we have written a macro which performs the following:

    - Open a blank Word document containing a table consisting of two rows (1st row: column headline, 2nd row: blank cells)
    - Link this document to a tab-delimited text file with descriptions and amounts (via mailmerge)
    - Stand in the first free cell (cell A2)
    - Loop through the fields in the text file via mailmerge, where selection. typetext fills a cell with an amount, after which selection. moveright goes to the right table cell. After that this cell is filled again, after which it moves to the next cell, etcetera. The table is thus getting longer and longer (Word ensures that rows are added automatically, just like manual typing in a Word table.

    Eventually, all fields have been inserted in the table and the end result is a beautifully drawn up financial annual report of e. g. 6 pages, complete with totals, amount formatting, header text and page numbering from a certain page number, in the style we want it to be. An example:

    (Example removed because I'm a new user).

    The above is a bit brief but this is largely the effect. It also works perfectly, except for 1 very big problem:
    It runs s-u-p-e-r slow. Since Word 97 we have owned all Word versions, and where Word 97 still worked very fast with this macro, it is so slow in Word 2013 (and 2016) that you can easily drink your cup of coffee, walk to the kitchen, make a new pot of coffee, pour in, walk back to the workplace, and then the macro is still busy and running.

    Question: What can we do to speed up the implementation of VBA? We have already tried the following:
    - Turn off screenupdating
    - Disable Spelling and grammar check
    - Other tips and tricks we found on the web

    This has only had marginal results, for example, it only shortens the runtime with a few seconds (of the many minutes it takes now).
    Surely it cannot be that a modern Word version, on Windows 10, on a very fast computer, is so slow?

    We have thought of alternatives such as using Excel, but the problem is that the end result should be included in a Word document, where the pagination of the annual report is extremely important. The data may even be split across the left and right pages. So on the left-hand side of the left-hand side of the table, on the right side the right-hand side of the table (while they are still two separate tables).
    Thursday, November 30, 2017 10:18 AM

All replies

  • Hello,

    Thanks for posting in MSDN forum.

    Could you share us your VBA code and a simply tab-delimited text file so we could try to reproduce your issue? You could share the text file via Cloud Storage, such as One Drive, and then put link here. Thanks for understanding.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 1, 2017 1:27 AM