X is the issue to this macro



Hello from Steved

8 IRISH DIAMOND 4 68X534
13 SILK N SATIN 055

The below macro will highlite 8 IRISH DIAMOND and 13 SILK N SATIN

8 IRISH DIAMOND X4 68534
13 SILK N SATIN X4 68534

The below macro will highlite 8 IRISH DIAMOND X4 68534 and 13
SILK N SATIN X4 68534


With the below macro how can I make it highlite "8 IRISH DIAMOND" and "13
SILK N SATIN" not '8 IRISH DIAMOND X4 68534" and "13 SILK N
SATIN X4 68534"

The issue is the X


Sub Highliter()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "[0-9 ]{1,}[A-Z ]{1,}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "[A-Z ]@>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
ActiveDocument.Save
Selection.Font.Color = wdColorRed
Options.DefaultHighlightColorIndex = wdYellow
Selection.Range.HighlightColorIndex = wdYellow
Selection.HomeKey Unit:=wdLine
End Sub

Thankyou
.



Relevant Pages

  • RE: Search email for text string to use in filename - save email t
    ... The code for my macro is below. ... .MatchWholeWord = False ... Dim sNewFileName As String ... > 0 Then Exit Function ...
    (microsoft.public.outlook.program_vba)
  • Re: Bug
    ... "Russ" wrote: ... Ok the only way I know how to repeat the macro, is to find the next number ... Fav 1:0:0:1 ... .MatchWholeWord = False ...
    (microsoft.public.word.vba.general)
  • Re: Macros search same word again and again.Help
    ... Run this macro with .MatchWholeWord set to "True" ... Dim oRng As Word.Range ... Greg Maxey - Word MVP ... If the macro finds words like alleged, ...
    (microsoft.public.word.vba.general)
  • Re: Macro works in Word 2007, but not in Outlook 2007
    ... I just briefly describe what this macro used to do; ... Keep your Outlook categories organized! ... .MatchWholeWord = False ... .MatchAllWordForms = False ...
    (microsoft.public.outlook.program_vba)
  • Re: Bug
    ... "Russ" wrote: ... Dim aRange As Range ... Ok the only way I know how to repeat the macro, is to find the next number ... .MatchWholeWord = False ...
    (microsoft.public.word.vba.general)