View Single Post
 
Old 04-12-2013, 07:33 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your code has many inconsistencies in the way you have used the variables for the bold and italics. You should fix those.

Your 'Replase_New' sub could be simplified:
Code:
Sub Replase_New(FFText As String, FFName As String, FFBold As String, FFItalic As String, _
    RFFText As String, RFFName As String, RFFColor As WdColor, RFFBold As String, RFFItalic As String, _
    bFormat As Boolean, bCase As Boolean, bWholeWord As Boolean, bWildcards As Boolean)
    With ActiveDocument.Range.Find
        .ClearFormatting
        .Text = FFText
        With .Font
          If FFBold = "True" Then .Bold = True
          If FFBold = "False" Then .Bold = False
          If FFItalic = "True" Then .Italic = True
          If FFItalic = "False" Then .Italic = False
        End With
        With .Replacement
            .ClearFormatting
            .Text = RFFText
            With .Font
                .Color = RFFColor
                .Name = RFFName
                If RFFBold = "True" Then .Bold = True
                If RFFBold = "False" Then .Bold = False
                If RFFItalic = "True" Then .Italic = True
                If RFFItalic = "False" Then .Italic = False
            End With
        End With
        .Forward = True
        .Wrap = wdFindContinue
        .Format = bFormat
        .MatchCase = bCase
        .MatchWholeWord = bWholeWord
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = bWildcards
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Also, whenever you're using wildcards, you should specify both a Find string and (unless you want to delete the found text) a Replace string. For example:
Code:
Call Replase_New("*", "Cambria", "True", "True", "^&", "Clarendon Indologique", wdColorGreen, "True", "True", True, False, False, True)
You'll see that I've inserted '*' and '^&' for the Find and Replace expressions. Also, where you don't care about whether the Find and Replace strings are bold or italic, you can simply leave both empty or use something like "Null". That way, instead of having three lines for 'Call Replase_New(FinderArray_abr(count)' you could have one:
Code:
Call Replase_New(FinderArray_abr(count), "", "Null", "Null", ReplaseArray_abr(count), "Charter Capital", wdColorBlue, "False", "False", True, True, False, False)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote