Hi John,
I'm sorry, but that is just so wrong that it left me shaking my head and
wondering where to start explaining.
In VBA, as in any programming language, there are various kinds of "things".
Part of the language is a set of rules that define how you can put the
"things" together, and any arrangement that doesn't match the rules is
"wrong".
In this case, .Replacement.Text is a String quantity. That is, it's a
sequence of bytes of memory, each of which can hold a character. You can't
put anything in it except strings of characters -- that's one of the rules.
The expression Selection.InsertBreak wdSectionBreakNextPage is a command to
perform an action. It isn't a String -- not even close. Using the & operator
to attach a string to the end of it doesn't help. In fact, I can't even make
Word run this code; it stops with the message "Compile error: Syntax error",
meaning the line doesn't obey the rules of VBA.
Besides that, even if you make the lines agree with the rules, your code
snippet won't do anything because you never called the .Execute method of
the .Find object. It's as if you filled in all the boxes on the Replace
dialog but never clicked any of the buttons to start the search.
In fact, there is no way to do what you're trying to do by a replacement.
Instead, you need to find the text of interest (and I suspect you don't
really *always* want to find the date APR 1-2005, do you? but that's a
separate issue) and then insert the break before it, something like this:
With Selection.Find
.Text = " APR 1-2005 "
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
If .Execute Then
Selection.Collapse wdCollapseStart
Selection.InsertBreak wdSectionBreakNextPage
End If
End With