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

Re: Speed of macros reduced to a snail pace by Word

Word
Mon Aug 22 05:33:00 CDT 2005

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
>
>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
>


Re: Speed of macros reduced to a snail pace by Klaus

Klaus
Tue Aug 23 05:11:10 CDT 2005

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


"Dave Neve" <NoAddressForSpammers@Nofs.fr> wrote:
> 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
>
>



Re: Speed of macros reduced to a snail pace by Helmut

Helmut
Tue Aug 23 06:08:36 CDT 2005

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"

Re: Speed of macros reduced to a snail pace by Klaus

Klaus
Tue Aug 23 07:32:28 CDT 2005

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


"Helmut Weber" <red.sys@t-online.de> wrote:
> 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"



Re: Speed of macros reduced to a snail pace by Dave

Dave
Thu Aug 25 03:46:53 CDT 2005

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

"Word Heretic" <myfullname@tpg.com.au> a écrit dans le message de news:
i9ajg1horv12f5c78ik95b35s40kep7j5p@4ax.com...
> 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
>>
>>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
>>
>



Re: Speed of macros reduced to a snail pace by Word

Word
Wed Aug 31 12:36:26 CDT 2005

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
>
>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
>
>"Word Heretic" <myfullname@tpg.com.au> a écrit dans le message de news:
>i9ajg1horv12f5c78ik95b35s40kep7j5p@4ax.com...
>> 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
>>>
>>>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
>>>
>>
>