![]() |
|
|
|
#1
|
||||
|
||||
|
It would be helpful if you actually posted the code ... How else do you expect anyone to say how you can make it better?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
You're right - sorry.
Code:
Function CountSpaces() As Integer
Dim doc As Document: Set doc = ActiveDocument
Dim rngFind As Range
On Error GoTo EndOfSub
Application.ScreenUpdating = False
Call ClearFind
If Selection.Type < 2 Then
Set rngFind = doc.Range
Else
Set rngFind = Selection.Range
End If
CountSpaces = 0
With rngFind
With .Find
.Text = "^32{2;}"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
If Len(rngFind.Text) > CountSpaces Then _
CountSpaces = Len(rngFind.Text)
.End = .End + 1
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
EndOfSub:
End Function
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Help!! find two number recurring numbers in row??
|
carrolld2 | Excel | 5 | 06-28-2014 05:43 PM |
macro to find a character and insert space so autocorrect will expand
|
redzan | Word VBA | 3 | 05-22-2014 04:22 PM |
Help with the "find and replace" option; character problem
|
martinn4 | Word | 3 | 02-20-2014 03:52 AM |
Conditional tied to trying to find a " " space character
|
Dart82 | Word VBA | 3 | 10-04-2013 01:47 PM |
| Concatenated data in subsequent rows | doorsgirl | Excel | 4 | 09-15-2011 10:37 PM |