
RegEx - my personal illogical nightmare
H'ye,
I'm stuck. I am using Word97 (where apparently RegEx is NOT RegEx as
we used to know them...).
What I want to achieve:
Find a single asterisk (*) in the document and have it formatted and
aligned like that:
texttexttexttexttext
texttexttexttexttext
*
texttexttexttexttext
texttexttexttexttext
What I already got (or not, who knows) is the first part: Find the
asterisk and insert the empty lines (or, if there are more lines
before or after, delete them).
With ActiveDocument.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "([!^13])^13{1;}\*^13{1;}([!^13])"
.Replacement.Text = "\1^13^13*^13^13\2"
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
Showing as here:
texttexttexttexttext
texttexttexttexttext
*
texttexttexttexttext
texttexttexttexttext
But I can't get the second part (the center alignment) working.
I have found out that it's probably the way I replace the ^13.
Call ClearFindAndReplaceParameters
With ActiveDocument.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Text = "^13\*^13{2}"
.Replacement.Text = "^13*^13^13"
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
This not only aligns the wanted ^13*^13^13, but the preceding and the
following lines as well. Hmpf.
I've read on the MVPS site that I must not use the ^13 in the replace
string, but instead ^p. But this gets me the error 5624. I CAN'T use
^p. - Or can I?
As said, I'm using Word97.
And as said, I'm stuck. :-]
See ya
Peter