G'day "HiThere" <
[email protected]>,
<SHUDDERS>
Right - this is EXACTLY why I COMPLAIN about the multiple DIM
statement. All the MVPs went "Who the frip cares, you're on drugs' and
here it is again.
To quote myself "It introduces it's own error type, so avoid it." I
sell a book on optimising VBA with a whole bunch of stuff.
Dim strFind, strReplaceWith, strMessage, strTitle As String
MATE - this is the equivalent of
Dim strReplaceWith as variant
Dim strMessage as variant
Dim strTitle As String
THIS IS NOT WHAT YOU WANTED!!!!! Stop trying to be 'memory efficient',
spell it out longhand, one variable per line, and then comment them
where neccesary. You are only causing yourself grief. Yes, these
variants ARE SLOWING YOUR CODE DOWN.
Dim strFind as String, strReplaceWith as String, strMessage as String, strTitle As String
Is the proper way to code that stupid long line, so hell man, an extra
dim (tokenised) is NOT going to make any damn difference.
Additionally, if you start using custom objects and that line fails,
you wont know which object caused the fail!
Next, your re-use of StrMsg. Dude, lets make it translation friendly
here please. Again, you are achieving NOTHING over a
Msgbox "Whatever the hell"....
Public Sub Whatever()
Const msgFindText as String = "....
Const msgReplaceText as String = "...
This is known as Internationalisation.
Use for each rather than for by.
Set your contexts so you can re-use the current object in context. You
do this with the With statement.
After a good find, collapse your range to its end and extend it to end
of block.
Finally, and most importantly, it is the PP that must be saved, not
the host doc (forcing the client save as well).
Do all this and be amazed at the speed increase!
Steve Hudson - Word Heretic
steve from wordheretic.com (Email replies require payment)
Without prejudice
HiThere reckoned: