Wildcard search is sulking

E

Elliott Roper

After playing about with wildcard search with mack's three space
problem, my v.X has given up on {m,n} style match counts. It appears to
use {1} regardless of the values of m and n.
e.g if the file contains "buggered", ug{1,}e fails.

I found some stuff about "wildcard search karma" on the mvp site
http://word.mvps.org/FAQs/MacrosVBA/index.htm
"Flush bad karma from Word's find facility after an unsuccessful
wildcard search"
.....for Windows Word that looked relevant but the macro supplied to
reset the wildcard search did not work because the
"ClearFindAndReplaceParameters" function does not exist on this pore
l'il Macca.

I have tried the other magics like losing normal, settings (10), carbon
registry, etc, but none of that helped.

The rest of wildcards works ok (for the small values of OK that apply
to Word's regexp). For instance "ug@e" finds "ugge" OK.

Now why did I choose that particular example word?

Is there anything else I can try to reset wildcard search short of
binning the whole damn thing and using emacs and TeX?
(even emacs' regexps are a tiny bit weird, and have I mentioned that I
*hate* regexps?)
 
K

Klaus Linke

Hi Elliott,

As I heard, some wildcard stuff wasn't implemented properly in Word X.

{n,m} might only work in Word2004. Thinkl I heard something along those
lines in the newsgroups.

If a restart of Word doesn't help, that's the only likely explanation.

ClearFindAndReplaceParameters() is another macro that you find if you click
on the macro name (hyperlink) in the article.
Though it won't help you if WordX doesn't handle that expression properly.

If you say it "fails" you mean it doesn't find anything? You don't get an
error message?

It would always fail in any version if you are somewhere in "ugge" when you
start the search, because Find searches downward from the insertion point to
the end of the document, and then from the start of the document to your IP.

It could also fail if the field separator on your installation isn't a
semicolon. For example, it's a comma on a German Mac.
But in that case, you'd get an error message about an invalid wildcard
pattern.

Regards,
Klaus
 
B

Beth Rosengard

Hi Elliott,

When I read your post this morning, I emailed John McGhie because I didn't
know when he'd get here next. Here's what he had to say:

---------------------
Can you please tell Elliott to add three statements before his macro Find or
replace:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.ClearAllFuzzyOptions

That will do the same thing. He also should record a macro to do a simple
search. The recorder records all the language needed to clear all of the
properties apart from the three above.
---------------------

Since I don't know anything about VBA, you'll have to save any questions for
him (or Klaus).

Cheers,

Beth
 
B

Beth Rosengard

Hi again,

We contacted Bill Coan who wrote the article and he added:

-------------------------------
You and John are both correct. The "ClearFindAndReplaceParameters" function
doesn't exist natively in Word VBA on the PC or the Mac. However, it does
exist at the MVP website, and in fact there is a link to it in the article
that you mentioned. (Unfortunately, the link looks like an ordinary
line of code, until you mouse over it.)

The link points to a separate article that contains the code for the
function. That article is here:

<http://word.mvps.org/FAQs/MacrosVBA/ClearFind.htm>
------------------------------

John says that Bill's code is better than his and to check the above URL
:). Also, he (John) will fix the article on the mvps.org site so the
proper code is in the source article.

Thanks for pointing this out!

Beth
 
E

Elliott Roper

Klaus Linke said:
Hi Elliott,

As I heard, some wildcard stuff wasn't implemented properly in Word X.

{n,m} might only work in Word2004. Thinkl I heard something along those
lines in the newsgroups.

It was working OK, then Word crashed in the middle of a search that was
going to fail (It was possibly one containing (expression){0,} before I
read that part of the help that explained 0 was invalid. I am almost
sure whatever it was was not being tried for the first time) When I
next started Word all x{m,n} searches behaved as x{1} - in other words
as though {m,n} was not present. That misbehavior has survived all the
usual preferences, normal template, incantations I know or could learn
from the MVP site, cache tidy-ups and a reboot.
If a restart of Word doesn't help, that's the only likely explanation.

ClearFindAndReplaceParameters() is another macro that you find if you click
on the macro name (hyperlink) in the article.
Though it won't help you if WordX doesn't handle that expression properly.

If you say it "fails" you mean it doesn't find anything? You don't get an
error message?
Nope, as described above, expression{m,n} behaves as though it were
expression.
It would always fail in any version if you are somewhere in "ugge" when you
start the search, because Find searches downward from the insertion point to
the end of the document, and then from the start of the document to your IP.

Heh! I wasn't *that* mean to it.
It could also fail if the field separator on your installation isn't a
semicolon. For example, it's a comma on a German Mac.
But in that case, you'd get an error message about an invalid wildcard
pattern.
You have lost me there. Do you mean the separator between m,n in {m,n}
expression? Only a comma fails to get an error message. Language is
British as is keyboard.

This is becoming a bit of a saga. (See also my reply to Beth in this
thread)

thanks Klaus. It was your article in the MVP site I was hoping for a
Mac equivalent of.
 
E

Elliott Roper

Beth Rosengard said:
Hi Elliott,

When I read your post this morning, I emailed John McGhie because I didn't
know when he'd get here next. Here's what he had to say:

---------------------
Can you please tell Elliott to add three statements before his macro Find or
replace:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.ClearAllFuzzyOptions

Tried that. The recorded macro for simple search did the first two.
Added the third (Selection.Find.ClearAllFuzzyOptions) to it and ran it.
It was no improvement. If I set the search string to "ug{1,}e" and run
the Macro via the keyboard shortcut I assigned, nothing happens. The
insertion point stays at the beginning of the document. If the search
string in the macro is changed to something else that it can find, the
macro operates as expected.

I may not have described this problem properly. The expression{m,n}
thing is failing in interactive search and replace, not just inside a
macro although it does that too.

It was working, then Word crashed and it has not worked since.
That will do the same thing. He also should record a macro to do a simple
search. The recorder records all the language needed to clear all of the
properties apart from the three above.
---------------------
For completeness, the modified recorded macro that failed to restore
normal operation is:-

Sub WildKarma()
'
' WildKarma Macro
' Macro recorded 31-08-2005 by Elliott Roper
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
' The following line was pasted into the recorded macro from Beth's post
Selection.Find.ClearAllFuzzyOptions
With Selection.Find
.Text = "ug{1,}e"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub
Since I don't know anything about VBA, you'll have to save any questions for
him (or Klaus).
Cheers,

Beth

Thanks heaps Beth
cheers
Elliott
 
E

Elliott Roper

Beth Rosengard said:
Hi again,

We contacted Bill Coan who wrote the article and he added:

-------------------------------
You and John are both correct. The "ClearFindAndReplaceParameters" function
doesn't exist natively in Word VBA on the PC or the Mac. However, it does
exist at the MVP website, and in fact there is a link to it in the article
that you mentioned. (Unfortunately, the link looks like an ordinary
line of code, until you mouse over it.)

The link points to a separate article that contains the code for the
function. That article is here:

<http://word.mvps.org/FAQs/MacrosVBA/ClearFind.htm>
------------------------------

John says that Bill's code is better than his and to check the above URL
:). Also, he (John) will fix the article on the mvps.org site so the
proper code is in the source article.

Thanks for pointing this out!

Beth

Thanks again Beth. The code in the clearfind article is more or less
exactly what I got by adding John's lines to the clear recorded macro
he suggested, give or take sticking it inside the with.

It has not succeeded in jolting my Word back into sanity.
I think I might live without {m,n} since nearly all of that that is
useful can be done with (expression)@

I wish all this "Power" did not have so much fragility as a side
effect. (Hi Jeff W! I have been following your thread with interest and
much head nodding)
 
Top