View Single Post
 
Old 05-24-2014, 11:07 PM
NobodysPerfect NobodysPerfect is offline Windows 7 64bit Office 2010 32bit
Competent Performer
 
Join Date: Jan 2014
Location: Germany
Posts: 136
NobodysPerfect is on a distinguished road
Default

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
NP
Reply With Quote