D
Designingsally
Hi
I was wondering if the macros can do this. I have code for find and replace.
The code works perfectly fine. But I want the way the output to be displayed
differently.
I want a dialog box it shd be divided into two parts. The top part of the
box should contain the sentence which has the mistaken[FIND WORD] word. The
mistaken word should displayed in green. The bottom part should have
suggestion words [REPLACE WORD].
Further the dialog box must YES , NO, AND IGNORE buttons. On clicking:
Yes- the word must be replaced
No- skip and go to next word
IGNORE- the checking shd get over.
ALL THIS SHD HAPPEN SEQUENTIALLY. If the are 2 different words eg, hi and
hello. When the macros encouter hi, change must occur.When the macros
encouter hello,change must occur. If the document has 10 hi's and 5 hello's.
Changes must occur as and when HI and HELLO occur. NOT change all 10 HI's at
one shot and then change all 5 HELLOS at one shot.
For example,
I have a pen. The pen is great. This pen is lovely. I like lovely things.
The code I got I have is
Dim orng As Range
Dim sRep As String
Dim sFindText As String
Dim sRepText As String
sFindText = "pen" 'the word to find
sRepText = "pencils" 'the word to replace
With Selection
..HomeKey wdStory
With .Find
..ClearFormatting
..Replacement.ClearFormatting
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set orng = Selection.Range
sRep = Msgbox("Replace?", vbYesNoCancel)
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
orng.Text = sRepText
End If
Wend
sFindText = "lovely" 'the word to find
sRepText = "bad" 'the word to replace
With Selection
..HomeKey wdStory
With .Find
..ClearFormatting
..Replacement.ClearFormatting
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set orng = Selection.Range
sRep = Msgbox("Replace?", vbYesNoCancel)
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
orng.Text = sRepText
End If
Wend
It will be great if someone comes up with a solution.
Thanks for helping a novice.
Sally
I was wondering if the macros can do this. I have code for find and replace.
The code works perfectly fine. But I want the way the output to be displayed
differently.
I want a dialog box it shd be divided into two parts. The top part of the
box should contain the sentence which has the mistaken[FIND WORD] word. The
mistaken word should displayed in green. The bottom part should have
suggestion words [REPLACE WORD].
Further the dialog box must YES , NO, AND IGNORE buttons. On clicking:
Yes- the word must be replaced
No- skip and go to next word
IGNORE- the checking shd get over.
ALL THIS SHD HAPPEN SEQUENTIALLY. If the are 2 different words eg, hi and
hello. When the macros encouter hi, change must occur.When the macros
encouter hello,change must occur. If the document has 10 hi's and 5 hello's.
Changes must occur as and when HI and HELLO occur. NOT change all 10 HI's at
one shot and then change all 5 HELLOS at one shot.
For example,
I have a pen. The pen is great. This pen is lovely. I like lovely things.
The code I got I have is
Dim orng As Range
Dim sRep As String
Dim sFindText As String
Dim sRepText As String
sFindText = "pen" 'the word to find
sRepText = "pencils" 'the word to replace
With Selection
..HomeKey wdStory
With .Find
..ClearFormatting
..Replacement.ClearFormatting
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set orng = Selection.Range
sRep = Msgbox("Replace?", vbYesNoCancel)
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
orng.Text = sRepText
End If
Wend
sFindText = "lovely" 'the word to find
sRepText = "bad" 'the word to replace
With Selection
..HomeKey wdStory
With .Find
..ClearFormatting
..Replacement.ClearFormatting
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set orng = Selection.Range
sRep = Msgbox("Replace?", vbYesNoCancel)
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
orng.Text = sRepText
End If
Wend
It will be great if someone comes up with a solution.
Thanks for helping a novice.
Sally