View Single Post
 
Old 02-19-2015, 03:48 AM
dherr dherr is offline Windows 8 Office 2007
Advanced Beginner
 
Join Date: Nov 2014
Location: Austria
Posts: 45
dherr is on a distinguished road
Default Macro does not run properly

Hi,
I have the following VBA-Code:
Code:
Sub FindRedcoloredText()
Dim i As Integer
i = 0
Application.ScreenUpdating = False
Do
    With selection.Find
        .ClearFormatting
        .Font.color = wdColorRed
        .text = ""
        .Replacement.text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            i = i + 1
            Debug.Print CStr(i) + ". " + selection.text + " " + CStr(selection.Range.ComputeStatistics(wdStatisticPages))
        Else
            Exit Do
        End If
    End With
Loop
Application.ScreenUpdating = True
End Sub
All words of my document should be found.
When I run this macro it finds sometimes 10, sometimes 1200, sometimes only 4 words which are colored red and then the macro runs 'out of time#, you see the waiting cursor of windows but nothing happens and I have to use Taskmanager to end Word. In the doc are about 3000 red words.
What can it be?

Regards-
Dietrich
Reply With Quote