Group: microsoft.public.word.vba.general
From: Nomey
Date: Thursday, November 29, 2007 11:08 AM
Subject: Evaluating the previous and following character in a Search and Replace routine?

Hi all,

Is there a way to evaluate the character before and after the found string in a routine like this:


With rTmp.Find
.ClearFormatting
.Text = var1
.MatchWholeWord = True
.MatchWildcards = False
'evaluate character here?
.Replacement.ClearFormatting
.Replacement.Text = var2
.Execute Replace:=wdReplaceAll
End With



Something like:

If 'prevous charecter is a tab or a carriage return or ". " Then
'use a capital for the first character in the replacement string
Else 'use no initial capital in the replacement string
End If


Best regards,
Shirley