Macros slow in Word 2003

B

Bill McClellan

Macros that work fine in Word97 and 2000
are taking twice as long to complete in
Word2003 on an XP machine.

Thanks for you help.
 
M

Malcolm Smith

Bill

I expect that this is a question as to why they take twice as long. May
we see some of the code so that we can see what's causing the issue?

- Malc
www.dragondrop.com
 
B

Bill McClellan

Malc,

Here's some sample code from one of the macros.

Thanks,

Bill

' This macro changes the font for certain Czech characters.

' ROMAN ACCENTS========================================
Selection.Find.ClearFormatting
With Selection.Find.Font
.Bold = False
.Italic = False
End With

Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Name = "WP MultinationalA Roman"
.Bold = False
.Italic = False
End With

' lower case c caron (hacek)

With Selection.Find
.Text = ChrW(269)
.Replacement.Text = ChrW(61573)
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

' lower case u ring
With Selection.Find
.Text = ChrW(366)
.Replacement.Text = ChrW(61671)
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
 
H

Howard Kaikow

Use With ... End With to eliminate unnecessary object references.
Use Range object instead of the Selection object.
Disable Office plug-in for norton auntie virus, if you have nav, but keep
nav's autoprotect enabled.
 
B

Bill McClellan

Howard,

Thanks for your suggestions. I don't have Norton installed and
I turn off my antivirus when testing the macros.

All my macros run fine in Word 97 and Word 2000 but all of them take
twice as long to process in Word 2003 (using XP on a faster machine).
If the cause of this slowdown is related to how Microsoft is
processing the VBA commands, I would have thought that Microsoft would
have mentioned the change.

Has Microsoft slowed down the processing of Selection objects in Word
2003 as opposed to how fast it handles them in 97 and 2000?

Bill
 
J

JB

Bill said:
Howard,

Thanks for your suggestions. I don't have Norton installed and
I turn off my antivirus when testing the macros.

All my macros run fine in Word 97 and Word 2000 but all of them take
twice as long to process in Word 2003 (using XP on a faster machine).
If the cause of this slowdown is related to how Microsoft is
processing the VBA commands, I would have thought that Microsoft would
have mentioned the change.

Has Microsoft slowed down the processing of Selection objects in Word
2003 as opposed to how fast it handles them in 97 and 2000?

Bill
Hi Bill,

The selection object is vastly slower that the range object as I've
found lately. I re-coded something using ranges and it was 10 seconds
faster than the old code using selections (damd big document of course).

Have a look at this article about ranges
http://msdn.microsoft.com/library/d...ry/en-us/modcore/html/deovrTheRangeObject.asp
and this should get you started.

I've noted also that Word XP & 2003 are slower than 2000 (possibly due
to translation of VBA into .NET) but that's just my experience. Also
try not to test over network shares and keep all macros for your users
on the C: drive (possibly with a logon script if you have that choice,
making updates much easier also).


HTH

J
 
H

Howard Kaikow

Word 97 handles documents quite differently than later versions, so there
can be significant performance hits, depending on how you did the code.

Word 2000 handles things differently than Word 2003, I just ran cross an
example a few weeks ago, don't recall where.

These changes particularly affect the Selection object. Less impact if you
use the Range object.
 
H

Howard Kaikow

JB said:
I've noted also that Word XP & 2003 are slower than 2000 (possibly due
to translation of VBA into .NET) but that's just my experience. Also
try not to test over network shares and keep all macros for your users
on the C: drive (possibly with a logon script if you have that choice,
making updates much easier also).

There is no .NET code, it is still VBA.
 
B

Bill_McC

One of my macros consistently takes 1 min 8 sec on Word 2000 and and
8 min 15 sec on Word 2003 which is just too slow for users. All my other
macros which use a variety of VBA code also take longer.

I haven't been able to find anything from Microsoft warning of a
possible slowdown in Macros in Word 2003 because of changes
in how it handles VBA code so I'm unsure of how I would need to
rewrite them.

Thanks for your help.

Bill
 
H

Howard Kaikow

Use the range object as a first step.
Use With ... End With to reduce object references.

There is no general answer, the full code would need to be examined.
I have a client for which I reduced execution time by 99.2%, and there was
still room for improvement, but it took a lot of code rewrite to get there.

Also, if you have norton auntie virus, disable the nav office plug-in, but
keep nav's autoprotect enabled.

Your code is likely doing something that is less efficient than it could be
and got caught by some change in Word 2003.
 
B

Bill_McC

Ok. Thanks for your help.

Bill


Howard Kaikow said:
Use the range object as a first step.
Use With ... End With to reduce object references.

There is no general answer, the full code would need to be examined.
I have a client for which I reduced execution time by 99.2%, and there was
still room for improvement, but it took a lot of code rewrite to get there.

Also, if you have norton auntie virus, disable the nav office plug-in, but
keep nav's autoprotect enabled.

Your code is likely doing something that is less efficient than it could be
and got caught by some change in Word 2003.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top