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 / August 2005

Tip: Looking for answers? Try searching our database.

Speed of macros reduced to a snail pace

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave Neve - 22 Aug 2005 10:59 GMT
Hi

I recently asked a question about two docs that use the same .dot as
reference to execute macros and install a toolbar.

One of the docs works very well while the other one (much longer table) has
become unusable due to the speed of execution

Today, I inserted a second table in the slow doc and the macros executed
right away.

So I have concluded that it is the length of the main table in the
problematic doc that is causing the problem and nothing else.

I have copied below one of the macros the speed of which seems to be
affected  by the length of the table.

Can anyone help me to get around this problem as I can't wait one minute
each time for a macro to execute.

I selcet the word with the cursor before running the macro.

Thanks in advance

Dave Neve

Sub FallingLong()

Dim wordrange As Range, lrange As Range, i As Long, j As Long
Set wordrange = Selection.Range
j = 2

   For i = 1 To wordrange.Characters.Count
   Set lrange = wordrange.Characters(i)

If Selection.Characters.Count <= 5 Then

   lrange.Font.Size = 18
   lrange.Font.Size = lrange.Font.Size - j
   j = j + 2
   lrange.Font.Spacing = 5
   wordrange.Font.Color = wdColorSkyBlue

Else

   lrange.Font.Size = 16
   lrange.Font.Size = lrange.Font.Size - j
   j = j + 1
   lrange.Font.Spacing = 5
   wordrange.Font.Color = wdColorSkyBlue

End If
Next i
Selection.Collapse Direction:=wdCollapseEnd

   Selection.ExtendMode = False
   Selection.Font.Reset

   Call NextWordSelect

End Sub
Word Heretic - 22 Aug 2005 11:31 GMT
G'day "Dave Neve" <NoAddressForSpammers@Nofs.fr>,

Don't iterate the characters collection. Instead, use a MoveStart to
move the start of your desired range along one character, and always
test .characters(1)

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice

Dave Neve reckoned:

>Hi
>
[quoted text clipped - 57 lines]
>
>End Sub
Dave Neve - 25 Aug 2005 09:46 GMT
Hi

This answer interests me but I don't really understand it.

What do you mean by 'iterate' and how do you use 'move start'.

Finally, what does test characters (1) do and how/where do I incorporate it
into the macro?

Sorry but I can't write macros really, I can only just about manipulate them
into docs and tolbars

Thanks in advance

> G'day "Dave Neve" <NoAddressForSpammers@Nofs.fr>,
>
[quoted text clipped - 71 lines]
>>
>>End Sub
Word Heretic - 31 Aug 2005 18:31 GMT
G'day "Dave Neve" <NoAddressForSpammers@Nofs.fr>,

For k= 1 to 10

K iterates from 1 to 10.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice

Dave Neve reckoned:

>Hi
>
[quoted text clipped - 85 lines]
>>>
>>>End Sub
Klaus Linke - 23 Aug 2005 11:11 GMT
Hi Dave,

And if it's long tables that are responsible for the slowness (which isn't
an issue with macros only, but also makes typing a pain):

It's pretty much the longest table(s) that determines the
speed/responsiveness. Many short tables are ok, one or several long tables
(spanning several tables) slow Word to a crawl.

With one large table, the responsiveness is about reciprocal to the table
length.

The only real solution is to split the longest tables. Setting the tables to
fixed width (rather than AutoFit to content/window) helps a bit, but not
much.

Greetings,
Klaus

> Hi
>
[quoted text clipped - 57 lines]
>
> End Sub
Helmut Weber - 23 Aug 2005 12:08 GMT
Hi Dave,

and besides all other good advices,
see http://tinyurl.com/c5nq8
for range vs. selection in tables regarding speed.

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Klaus Linke - 23 Aug 2005 13:32 GMT
Hi Helmut,

Yes! Dave Rado cam to quite similar conclusions:
http://www.word.mvps.org/faqs/tblsfldsfms/FastTables.htm
Pretty surprising, and likely due to some "sub-optimal" implementation?
Though I find the difference negligible in Word2003.
Not sure if Range became faster, or Selection slower ;-)

Regards,
Klaus

> Hi Dave,
>
[quoted text clipped - 8 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"

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.