J
Jason L
Helmut, et al,
Sorry for reposting this, but the initial post is around 2-3 weeks old and
buried. I was afraid it wouldn't get any attention. Here it is:
Helmut,
Hi, I am sorry this is so delayed, but I got caught up in some other
work before I could test the macro you supplied me. When I run the
macro, it gives me an error that says, the Find What contains a
Pattern Match that is not a valid Expression. Do you know what this
means or why I am getting this error?
Here is the code clipped from the larger macro:
ResetSearch
With Selection
.ExtendMode = False
.HomeKey unit:=wdStory
With Selection
.ExtendMode = False
.HomeKey unit:=wdStory
With .Find
.Text = "(^13)([A-z]{1;}.[^32^s^t]{1;})([!^13]{1;})"
.Replacement.Text = "\1\3"
.MatchWildcards = True
' define formatting
.Execute Replace:=wdReplaceAll
End With
End With
TIA,
Jason L
Sorry for reposting this, but the initial post is around 2-3 weeks old and
buried. I was afraid it wouldn't get any attention. Here it is:
Helmut,
Hi, I am sorry this is so delayed, but I got caught up in some other
work before I could test the macro you supplied me. When I run the
macro, it gives me an error that says, the Find What contains a
Pattern Match that is not a valid Expression. Do you know what this
means or why I am getting this error?
Here is the code clipped from the larger macro:
ResetSearch
With Selection
.ExtendMode = False
.HomeKey unit:=wdStory
With Selection
.ExtendMode = False
.HomeKey unit:=wdStory
With .Find
.Text = "(^13)([A-z]{1;}.[^32^s^t]{1;})([!^13]{1;})"
.Replacement.Text = "\1\3"
.MatchWildcards = True
' define formatting
.Execute Replace:=wdReplaceAll
End With
End With
TIA,
Jason L
Helmut Weber said:Hi Jason,
keep on!hm..., doesn't make any sense to me.With Selection.Find
.Text = " [ A-z].[^32^s^t]@"
.Replacement.Text = "1/^+"
The 1/ should probably be \1, but would require an expression
inclosed in parenthesis (). Apart from other complications,
and apart from the fact, that wildcardsearch needs quite a bit
of a trial and error approach, (and some things simply don't work),
here is what i've figured out:
Search for a paragraph starting with some letters followed by "."
(^13)([A-z]{1,}.)
Paragraph would be expression \1 later.
Instead of {1,} one should be able to use @, but doesn't work here.
Include whitespace after ".":
(^13)([A-z]{1;}.)([^32^s^t]{1,})
Again, ^w for whitespace doesn't work, therefore [^32^s^t]{1,}.
As the characters and the whitespace can be grouped together,
we arrive at:
(^13)([A-z]{1,}.[^32^s^t]{1,})
Now we got to search until the paragraphs end.
That would be one ore more characters, that are not chr(13).
([!^13]{1,})
All together it could look like:
"(^13)([A-z]{1,}.[^32^s^t]{1,})([!^13]{1,})"
So we got 3 expressions,
expression1 is the preceding paragraph mark, which we leave untouched,
expression2 is
the letters following, plus the period plus the whitespace
expression3 is the remainder.
Follows
.Replacement.Text = "\1\3"
which means "cut off expression \2".
Apply the formatting to the result.
Here is my test macro, which could be improved by using
range instead of selection, and in some more ways, I guess.
Sub Test661()
ResetSearch
With Selection
.ExtendMode = False
.HomeKey unit:=wdStory
With .Find
.Text = "(^13)([A-z]{1;}.[^32^s^t]{1;})([!^13]{1;})"
.Replacement.Text = "\1\3"
.MatchWildcards = True
' define formatting
.Execute Replace:=wdReplaceOne ' for testing
End With
End With
ResetSearch
End Sub
Public Sub ResetSearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
End Sub
HTH
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98