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


Helmut Weber <elmkqznfwvccbf@mailinator.com> wrote in message
news:<agosp0l7nsg9kphkv1dbag2am70mkvbj5a@4ax.com>...
> Hi Jason,
> keep on!
> > With Selection.Find
> > .Text = " [ A-z].[^32^s^t]@"
> > .Replacement.Text = "1/^+"
> hm..., doesn't make any sense to me.
> 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
> http://word.mvps.org/

Re: Wild Card Search II by Jay

Jay
Mon Dec 06 13:04:35 CST 2004

Hi Jason,

I haven't actually tried to run this, but I think the problem is the
semicolons in the two expressions {1;} -- they should be commas instead.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Jason L wrote:
> 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
>
>
> Helmut Weber <elmkqznfwvccbf@mailinator.com> wrote in message
> news:<agosp0l7nsg9kphkv1dbag2am70mkvbj5a@4ax.com>...
>> Hi Jason,
>> keep on!
>>> With Selection.Find
>>> .Text = " [ A-z].[^32^s^t]@"
>>> .Replacement.Text = "1/^+"
>> hm..., doesn't make any sense to me.
>> 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
>> http://word.mvps.org/



Re: Wild Card Search II by Helmut

Helmut
Tue Dec 07 03:59:20 CST 2004

Hi,

I think I'd better use a construction like
this in the future. When copying and pasting
from VBE to the newsreader editor it's almost
impossible not to mix up "," and ";" in the end.

sLst = Application.International(wdListSeparator)
' ...
If lst = ";" Then
.Text = "(^13)([A-z]{1;}.[^32^s^t]{1;})([!^13]{1;})"
Else
.Text = "(^13)([A-z]{1,}.[^32^s^t]{1,})([!^13]{1,})"
End If

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000