Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Macros slow in Word 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill McClellan - 02 Nov 2004 22:35 GMT
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.
Malcolm Smith - 03 Nov 2004 00:14 GMT
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
Bill McClellan - 03 Nov 2004 17:35 GMT
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
Howard Kaikow - 04 Nov 2004 08:20 GMT
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.
Signature

http://www.standards.com/; See Howard Kaikow's web site.

> Malc,
>
[quoted text clipped - 50 lines]
>     End With
>     Selection.Find.Execute Replace:=wdReplaceAll
Bill McClellan - 04 Nov 2004 15:21 GMT
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

> 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.
> --
JB - 04 Nov 2004 17:46 GMT
> Howard,
>
[quoted text clipped - 17 lines]
>>nav's autoprotect enabled.
>>--
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/default.asp?url=/library/en-us/modcore/html/de
ovrTheRangeObject.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
Howard Kaikow - 05 Nov 2004 09:16 GMT
> 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.
Howard Kaikow - 05 Nov 2004 09:14 GMT
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.
Signature

http://www.standards.com/; See Howard Kaikow's web site.

> Howard,
>
[quoted text clipped - 17 lines]
> > nav's autoprotect enabled.
> > --
Bill_McC - 05 Nov 2004 15:59 GMT
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

> Word 97 handles documents quite differently than later versions, so there
> can be significant performance hits, depending on how you did the code.
[quoted text clipped - 28 lines]
> > > nav's autoprotect enabled.
> > > --
Howard Kaikow - 05 Nov 2004 17:18 GMT
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.

Signature

http://www.standards.com/; See Howard Kaikow's web site.

>
> One of my macros consistently takes 1 min 8 sec on Word 2000 and and
[quoted text clipped - 42 lines]
> > > > nav's autoprotect enabled.
> > > > --
Bill_McC - 05 Nov 2004 19:32 GMT
Ok. Thanks for your help.

Bill

> Use the range object as a first step.
> Use With ... End With to reduce object references.
[quoted text clipped - 56 lines]
> > > > > nav's autoprotect enabled.
> > > > > --

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.