Discussion:
How to find the right arrow that AutoCorrect creates from "-->"
(too old to reply)
David Satz
2009-04-28 15:51:01 UTC
Permalink
Hi. In Word 2003 with default AutoCorrect options, if a user types the
sequence --> it will be replaced in the document by Wingdings character 224,
a solid right arrow.

I need to know how a macro can find all the places where this substitution
has occurred in a document. It's easy to do interactively using the Find
dialog--just clipboard an instance of the arrow character into the "Find
What" text box, and Find finds every arrow in the document. The Find dialog
even distinguishes between arrows that came about through substitution from
"-->" and the identical looking Wingding arrow symbol. But I haven't found
any way to find these substituted characters programatically (in a macro).

Word doesn't actually apply the Wingdings font to them in the normal way,
for example. If you select the arrow, the font dropdown says "Arial" or
whatever the font originally was when the user typed the --> combination. And
searching by character code doesn't find them, either.

The Immediate window gives a similar result: typing
?Selection.Range.Font.Name gives ... whatever the font of the --> sequence
was originally (not Wingdings), with a character code of 40 for the character
itself, which would normally be a left parenthesis. But if I use the Find
object search for that font and that character code, Find never finds the
right arrow.

Curiously, the RTF code shows that the sequence --> is still preserved in
the text after the substitution has been made, and I see no indication of the
Wingdings font being applied, either--so some rather mysterious processing
must be going on, I think. Unfortunately, that bit of knowledge does me no
good; searching for the character sequence --> with the Find object doesn't
find the Wingdings arrow.

Unfortunately in the publishing company that I work for, we use HTML-style
(or XML-style) comments which need to be located by a macro, and the macro
can't "see" the end of a comment (which has the form <!-- text of comment
-->) if the writer entered it with the default AutoCorrect options set.

All help appreciated.

--best regards
Jay Freedman
2009-04-28 16:49:35 UTC
Permalink
Hi David,

The code in http://www.word.mvps.org/FAQs/MacrosVBA/FindReplaceSymbols.htm
ought to help. It also "sort of" explains what Word is doing that causes all
the grief.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Post by David Satz
Hi. In Word 2003 with default AutoCorrect options, if a user types the
sequence --> it will be replaced in the document by Wingdings
character 224, a solid right arrow.
I need to know how a macro can find all the places where this
substitution has occurred in a document. It's easy to do
interactively using the Find dialog--just clipboard an instance of
the arrow character into the "Find What" text box, and Find finds
every arrow in the document. The Find dialog even distinguishes
between arrows that came about through substitution from "-->" and
the identical looking Wingding arrow symbol. But I haven't found any
way to find these substituted characters programatically (in a
macro).
Word doesn't actually apply the Wingdings font to them in the normal
way, for example. If you select the arrow, the font dropdown says
"Arial" or whatever the font originally was when the user typed the
--> combination. And searching by character code doesn't find them,
either.
The Immediate window gives a similar result: typing
?Selection.Range.Font.Name gives ... whatever the font of the -->
sequence was originally (not Wingdings), with a character code of 40
for the character itself, which would normally be a left parenthesis.
But if I use the Find object search for that font and that character
code, Find never finds the right arrow.
Curiously, the RTF code shows that the sequence --> is still
preserved in the text after the substitution has been made, and I see
no indication of the Wingdings font being applied, either--so some
rather mysterious processing must be going on, I think.
Unfortunately, that bit of knowledge does me no good; searching for
the character sequence --> with the Find object doesn't find the
Wingdings arrow.
Unfortunately in the publishing company that I work for, we use
HTML-style (or XML-style) comments which need to be located by a
macro, and the macro can't "see" the end of a comment (which has the
form <!-- text of comment -->) if the writer entered it with the
default AutoCorrect options set.
All help appreciated.
--best regards
David Satz
2009-04-28 23:25:01 UTC
Permalink
Jay, many thanks. The document that you referenced had a number of what
turned out to be false leads in this case--the "GetCharNoAndFont" macro, for
example, gives a result of -4044 for the character code, which is incorrect.

But on impulse I tried something that the article mentions, which is to
search for the character with the macro recorder running--since I'd noticed
that (again, contrary to what the article says w/r/t Word 2000, though I'm
using Word 2003) actually it works perfectly well if I clipboard the
character into the Find dialog and look for it that way.

In that way I discovered that the recorded macro used a character code of
61664. Using ChrW$(61664) as the Text value for a Find object in a macro
finds these characters, and in my application I don't need to be picky about
the font--so I've got what I need.

Many, many thanks.

--best regards

Loading...