E
Elaine J.
Can someone tell me what is wrong with this code? What I am trying to do, is
set a range to the first 5 sections of a document. Then I want to find a
particular string. If I find it, I want to clear that search and search for
something different. However, the search is not working (at all). It is
not finding the string that is actually in the document. (I tried changing
noticeplus.find to selection.find, which appeared to work. But as I got
deeper into the macro, I found that it was not doing what I wanted (It wasn't
just searching the range that I set, it was searching the entire document).
I know I have done this before and I know it is going to be something simple
and stupid, but it just has me stumped at the moment. Thanks for any help.
Dim noticeplus as range
Selection.HomeKey Unit:=wdStory
Set noticeplus =
ActiveDocument.Range(Start:=ActiveDocument.Sections(1).Range.Start,
End:=ActiveDocument.Sections(5).Range.End)
With noticeplus.Find
.ClearFormatting
.Text = "Electronic"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
If noticeplus.Find.Execute("Electronic") = True Then
Selection.Collapse 1
Selection.HomeKey Unit:=wdStory
Set noticeplus =
ActiveDocument.Range(Start:=ActiveDocument.Sections(1).Range.Start,
End:=ActiveDocument.Sections(5).Range.End)
With noticeplus.Find
.ClearFormatting
.Text = "in accordance with your contract"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
'Expert if
If noticeplus.Find.Execute = True Then
Selection.Collapse 1
Selection.HomeKey Unit:=wdStory
set a range to the first 5 sections of a document. Then I want to find a
particular string. If I find it, I want to clear that search and search for
something different. However, the search is not working (at all). It is
not finding the string that is actually in the document. (I tried changing
noticeplus.find to selection.find, which appeared to work. But as I got
deeper into the macro, I found that it was not doing what I wanted (It wasn't
just searching the range that I set, it was searching the entire document).
I know I have done this before and I know it is going to be something simple
and stupid, but it just has me stumped at the moment. Thanks for any help.
Dim noticeplus as range
Selection.HomeKey Unit:=wdStory
Set noticeplus =
ActiveDocument.Range(Start:=ActiveDocument.Sections(1).Range.Start,
End:=ActiveDocument.Sections(5).Range.End)
With noticeplus.Find
.ClearFormatting
.Text = "Electronic"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
If noticeplus.Find.Execute("Electronic") = True Then
Selection.Collapse 1
Selection.HomeKey Unit:=wdStory
Set noticeplus =
ActiveDocument.Range(Start:=ActiveDocument.Sections(1).Range.Start,
End:=ActiveDocument.Sections(5).Range.End)
With noticeplus.Find
.ClearFormatting
.Text = "in accordance with your contract"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
'Expert if
If noticeplus.Find.Execute = True Then
Selection.Collapse 1
Selection.HomeKey Unit:=wdStory