none
Macro much slower when mouse cursor is in document RRS feed

  • Question

  • We have a word macro that executes 6 times slower when the cursor (I-beam) is in the Word document.  Has anyone experienced this?

    Friday, May 2, 2014 8:54 PM

Answers

  • Confirmed, it seems the display drivers were the cause.

    Is this a known issue that affects the DoEvents method?

    There are too many different hardware/software combinations out there to say this is a 'known issue', especially when it comes to systems using two display cards. It would seem you have a hardware/driver conflict and that's the cause of the issue, rather than it being a problem with Word as such.

    Since it seems to affect DoEvents, you might find it worthwhile eliminating as many of those as is practical - even without driver issues they can slow a macro down when used unnecessarily.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by Marvin_Guo Monday, May 19, 2014 2:07 AM
    Monday, May 5, 2014 10:07 PM

All replies

  • That isn't the normal behaviour and it can probably be avoided by some code changes. Without seeing the macro, though, it's impossible to say.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Saturday, May 3, 2014 7:55 AM
  • The culprit seems to be the call to DoEvents.  It takes 150 - 200ms when the mouse cursor is on the document and 0ms when the cursor is off the document.

    The strange part is, the "issue" does not occur on all PCs we've tried it on.  It also seems to make a difference if AERO and / or a mouse theme is enabled.



    Monday, May 5, 2014 12:34 PM
  • Only very limited and general advice can be given without seeing the code:

    1. Turn off ScreenUpdating.

    2. Use Range objects, not Selections unless unavoidable.

    3. Turn of table auto-fit properties.

    4. Turn off track-changes.

    5. Where multiple ranges are to be processed, use built-in procedures that can process them in a single pass (e.g. Find/Replace) rather than looping through the range items and processing them iteratively.

    Your reference to only certain PCs exhibiting this behaviour, and only when Aero/mouse themes are enabled suggests a faulty display driver or display configuration. Check the maker's website for an updated driver and the errant PC display/mouse configurations against the well-behaved ones.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Monday, May 5, 2014 12:46 PM
  • The culprit seems to be the call to DoEvents.  It takes 150 - 200ms when the mouse cursor is on the document and 0ms when the cursor is off the document.

    We will review display drivers...

    Monday, May 5, 2014 2:02 PM
  • Confirmed, it seems the display drivers were the cause.

    Is this a known issue that affects the DoEvents method?

    Monday, May 5, 2014 3:35 PM
  • The PC has two video cards, the issue occurs on the Intel HD Graphics 3000 card with the latest drivers (9.17.10.3517)

    Monday, May 5, 2014 4:33 PM
  • Confirmed, it seems the display drivers were the cause.

    Is this a known issue that affects the DoEvents method?

    There are too many different hardware/software combinations out there to say this is a 'known issue', especially when it comes to systems using two display cards. It would seem you have a hardware/driver conflict and that's the cause of the issue, rather than it being a problem with Word as such.

    Since it seems to affect DoEvents, you might find it worthwhile eliminating as many of those as is practical - even without driver issues they can slow a macro down when used unnecessarily.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by Marvin_Guo Monday, May 19, 2014 2:07 AM
    Monday, May 5, 2014 10:07 PM