Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OK, you wildcard gurus!

98 views
Skip to first unread message

Dave Rado

unread,
Mar 24, 2002, 10:11:07 AM3/24/02
to
My users often paste stuff in from other companies' documents that have
straight quotes where smartquotes should have been used. I'd like to convert
those, while leaving inch signs alone. I'd also like to leave straight
quotes that are formatted in certain styles such as "Macro Text" alone. Is
this possible, using a wildcard Find and Replace?

Regards

Dave


Jay Freedman

unread,
Mar 24, 2002, 12:35:18 PM3/24/02
to
"Dave Rado" <dr...@onetel.net.uk> wrote in message
news:#uWfEf00BHA.1280@tkmsftngp04...

Hi, Dave,

For multiple conditions like that, it's easier to let them all be converted, and
then convert back the ones you don't want to affect. Try this:

Sub DiddleQuotes()
Dim bOptSmtQuot As Boolean

' save current setting & force True
bOptSmtQuot = Options.AutoFormatAsYouTypeReplaceQuotes
Options.AutoFormatAsYouTypeReplaceQuotes = True

Selection.HomeKey unit:=wdStory

' convert all straight quotes to smart quotes
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
.Text = Chr(34)
.Replacement.Text = Chr(34)
.Execute Replace:=wdReplaceAll
End With

Options.AutoFormatAsYouTypeReplaceQuotes = False

' convert quote after number to straight quote
With Selection.Find
.MatchWildcards = True
.Text = "([0-9])^0148"
.Replacement.Text = "\1" & Chr(34)
.Execute Replace:=wdReplaceAll
End With

' convert quote in Macro Text style to straight quote
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = True
.Style = "Macro Text"
.Text = "[^0147^0148]"
.Replacement.Text = Chr(34)
.Execute Replace:=wdReplaceAll
End With

Options.AutoFormatAsYouTypeReplaceQuotes = bOptSmtQuot
End Sub

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


Klaus Linke

unread,
Mar 24, 2002, 12:54:16 PM3/24/02
to


Hi Dave,

"you wildcard gurus"? Thought you were one of us ;-)
Looks like you have the usual question of how to replace straight
quotes with smart quotes, plus two complications.

One of them is easily taken care of, I think: Define "Macro Text" as
hidden temporarily, and don't show hidden text.

The inch signs ideally should have been inserted as real inch signs to
start with (U+2033 = ^8243). You will have difficulties
differentiating between closing quotes and wrong inch signs:
"Give me 20 3" nails -- no, make that 40", he said.

Assuming that inches only appear after numbers, I'd do a wildcard
find/replace
Find what: ([0-9])" ((straight quote))
Replace with: \1" ((where you type the inch sign with Alt+8243))
and go through the replacements one by one.

Greetings, Klaus


Dave Rado

unread,
Mar 25, 2002, 4:32:37 PM3/25/02
to
Hi Klaus and Jay (I'm replying to both of you in one post)

Re. wildcard gurus, when I see some of the messages you and others have
posted about wildcards, all I can do is prostrate myself on the ground and
say "I am not worthy!" :-)

Re. your two approaches to dealing with the "Macro Text" style, Klaus's idea
is very clever and does what I *said* I wanted (leaves the Macro Text
alone); whereas Jay's approach doesn't strictly speaking do what I said I
wanted, but it does do what I *really* wanted (it ensures that the styles in
question don't use Smartquotes). Never trust what anyone *says* they want!
<g> And it's only very slightly slower than Klaus's approach, even in long
documents. But I'm sure I'll find the hidden text trick useful in other
contexts, so thanks for that.

I agree with Klaus that you can't be certain that a number followed by a
quote means that the quote is meant to be an inch sign - I was hoping you
might have been able to come up with some magic recipe to work out which it
was for certain! <g> - so I have resorted to displaying a Message Box if the
macro finds a number followed by a quote and asking the user to choose.
Luckily, their documents almost never do contain numbers followed by quotes,
but better safe than sorry.

I had no idea that there was a Unicode character specifically for inch signs
(and for foot signs - ^8242) - great tip, thanks! Interestingly, in some
fonts (e.g. TNR), keyboard quotes and proper inch signs look very similar;
whereas in other fonts, such as Book Antiqua, keyboard quotes look awful in
comparison with proper inch signs.

In case anyone is interested my "inch sign" code now goes something like
this (plus t:

Dim Button As Long
Dim bOptSmtQuot As Boolean

bOptSmtQuot = Options.AutoFormatAsYouTypeReplaceQuotes
Options.AutoFormatAsYouTypeReplaceQuotes = True

With Selection.Find
.Text = "([0-9])"""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute
Button = MsgBox("Change the quote to an inch sign?" & vbCr & vbCr &
_
"(If you select 'No', it will be converted to a SmartQuote
instead)", vbYesNo)
If Button = vbYes Then
.Replacement.Text = "\1" & ChrW(8243)
Else


.Replacement.Text = "\1" & Chr(34)

End If
.Execute replace:=wdReplaceOne
Selection.Collapse wdCollapseEnd
Loop
End With

Options.AutoFormatAsYouTypeReplaceQuotes = bOptSmtQuot

'followed by a similar routine for replacing ' with ChrW(8242)
~~~

Regards

Dave


"Dave Rado" <dr...@onetel.net.uk> wrote in message
news:#uWfEf00BHA.1280@tkmsftngp04...

Klaus Linke

unread,
Mar 25, 2002, 6:37:20 PM3/25/02
to
Hi Dave, hi Jay,

Usually I prefer to use AutoFormat to fix quotes, because AutoCorrect
only works with English quotes (in an English version of Word), and I
have a lot of multilingual documents.

To give it another shot... Perhaps you *can* do a bit better with
wildcards than with AutoCorrect.

In a first step, I would replace all smart quotes with straight quotes
(so that you can easily find the problem cases that weren't fixed
after the Replace is done ... and changing the definition of style
"Macro Text" to "hidden" is back in the ball park <g>)

Then,
Find what: "<([!"]@)>"
Replace with: ^0147\1^0148

Single "widowed" quotes and inch-signs will usually remain straight
quotes. Inch signs will only be changed to smart quotes if they appear
in quotes (which should be so rare as to be without interest). Seems a
bit better than AutoCorrect (plus you can choose the kinds of quotes
to use).

Greetings, Klaus


Dave Rado

unread,
Mar 27, 2002, 11:17:27 AM3/27/02
to
Hi Klaus - apologies for the delay in replying.

That doesn't find:

1) Quotes that follow punctuation (I'm not sure why it doesn't).

2) Continuation paragraph quotes (i.e. when you're quoting someone speaking
for several paragraphs, it' s conventional, at least in the UK, to start
each of those paragraphs with an opening quote, but only to have a closing
quote when he stops speaking.

In the following example, which illustrates both points, your Find string
finds zero occurrences when I try it:

"Nobody," he said, as he slid down the banister;
"Nobody," he said, as he landed on his head;
"Nobody, but nobody could call me a fussy man -
"But I do like a little bit of butter on my bread."

Thanks for trying though - a very ingenious attempt. :-)

Regards

Dave

"Klaus Linke" <fotosatz...@t-online.de> wrote in message
news:a7ocbv$cig$05$2...@news.t-online.com...

Klaus Linke

unread,
Mar 27, 2002, 8:44:45 PM3/27/02
to
Hi Dave,

It looked like it *might* work ... should have tested it :-)

The following would work for your example, except for the continuation
paragraph quote:

Find what: "<(*)"([ .;,\!\?:\)\]/^13^11])
Replace with: ^0147\1^0148\2

You could replace "< with ^0147 afterwards to fix the opening quotes
for continuation paragraph quotes, but that would defeat the
possibility to find unmatched opening quotes.

I don't know your rules, but if unmatched opening quotes are only
allowed to appear at the beginning of a new line/paragraph, and if an
unmatched opening quote appeared in the line/paragraph above, you
could fix them with a second search:

Find what: (^0147[!^0147^0148"]@[^11^13])"([!^0147^0148"]@^0148)
Replace with: \1^0147\2

Hope there aren't many more complications ;-)

Greetings, Klaus

Klaus Linke

unread,
Mar 27, 2002, 9:07:33 PM3/27/02
to
That was a bit sloppy; better:
First
Find what: "<([!"]@)"([ .;,\!\?:\)\]/^13^11^2^5])

Replace with: ^0147\1^0148\2
then (for "continuation paragraph quotes")
Find what: "(<[!"^0147^0148]@^0147)
Replace with: ^0147\1

[ .;,\!\?:\)\]/^13^11^2^5] should cover every character that can
appear after a word (I hope).

Klaus

Dave Rado

unread,
Apr 1, 2002, 7:00:15 AM4/1/02
to
Hi Klaus - apologies again for the delay in replying.

[Bowing down and prostrating myself at your feet] We are not worthy!!

But I don't understand *how* it works - could you break it down?

Also, re:


"Usually I prefer to use AutoFormat to fix quotes, because AutoCorrect
only works with English quotes "

Can one use AutoFormat to replace all smart quotes with straight quotes?

Thanks and regards

Dave

"Klaus Linke" <fotosatz...@t-online.de> wrote in message

news:a7ttt6$nb$02$1...@news.t-online.com...

Jay Freedman

unread,
Apr 1, 2002, 10:52:01 AM4/1/02
to
Hi, Dave,

I see how it works, and I'm similarly awed...

As with any code expression, you have to deconstruct it from the innermost expression outward. The
core is

([!"]@)

meaning any one or more characters that are not straight quotes. The parens make this group
addressable in the replacement text as \1. The group is preceded by a < sign meaning "at the
beginning of a word".

Working outward, the next larger expression is

"<([!"]@)"

so the group being searched must be surrounded by straight quotes. Following that is the expression

([ .;,\!\?:\)\]/^13^11^2^5])

which is simply a set (surrounded by square brackets) of all the punctuation that could follow the
first expression: space, period, semicolon, comma, then the "escaped" (backslash-preceded) forms of
exclamation and question mark, colon, escaped right-parenthesis and right-bracket, forward slash,
paragraph mark, and line break. I don't recognize the ^2 and ^5 -- Klaus, what are they? Finally,
the whole thing is surrounded by parentheses so it can be addressed as \2 in the replacement. It
will represent only one character.

The "continuation paragraph" search deals with the convention that when a single speaker in dialog
has multiple consecutive paragraphs, only the last paragraph has a closing quote. All of the others
will have an unmatched opening quote, which will be left unchanged by the first search/replace.

To answer your question about AutoFormat, AFAIK AutoFormat only goes one way, straight -> curly. The
reverse is done by turning off the AutoFormat option and doing a ReplaceAll of straight -> straight;
somehow Replace manages to make a straight quote in the Find What box match straight and both kinds
of curly quotes.

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

"Dave Rado" <dr...@onetel.net.uk> wrote in message news:#5WnmUX2BHA.2324@tkmsftngp03...

Dave Rado

unread,
Apr 1, 2002, 3:46:41 PM4/1/02
to
Hi Jay

OK, I've got it now, although I've hit a new snag (which I'm coming to in a
moment).

Attempting to translate the first F&R into my bear-of-little-brain English:

Find: "<([!"]@)"([ .;,\!\?:\)\]/^13^11^2^5])

Translates to:

"Find a straight quote that is immediately followed by the beginning of a
word, followed by 1 or more characters, none of which are quotes (including
the first character of that word), and then another straight quote; with the
second straight quote being followed by either a space or paragraph mark (or
similar non-printing character); or by punctuation."

It successfully finds "Nobody," where the punctuation mark is before the
quote, because the punctuation mark qualifies as one of the "1 or more
characters, none of which are quotes". And it leaves the inch mark alone,
in:

"Hi" is a word. 3½" is a measurement.

... even if the cursor is on the H of Hi when you do the search, because
neither of those quotes are followed by the beginning of a word.


Having done that search, all the straight quotes other than inch signs will
have been converted to smartquotes, with the exception of the continuation
quotes. So the second search:

Find: "(<[!"^0147^0148]@^0147)

Translates to:

"Find a straight quote that is immediately followed by the beginning of a
word, followed by 1 or more characters, none of which are quotes (smart or
otherwise), followed by an *opening* smartquote."

Pure genius!

From what you say about Autoformat, I gather Klaus gave up trying to make
this work multilingually ...

BUT!

I tried to adapt all this to work for single quote characters (') as well
and immediately got stuck.


Find what: '<([!']@)'([ .;,\!\?:\)\]/^13^11^2^5])

... doesn't find anything at all, when I try it! Why not, and what's the
workaround?

Regards

Dave

"Jay Freedman" <jay.fr...@verizon.net> wrote in message
news:OrQQ#TZ2BHA.2816@tkmsftngp05...

Jay Freedman

unread,
Apr 2, 2002, 12:45:07 PM4/2/02
to
"Dave Rado" <dr...@onetel.net.uk> wrote in message news:e7HW76b2BHA.2216@tkmsftngp04...
> Hi Jay
>
[snip]
Yes, you translated correctly.

>
> Pure genius!
>
> From what you say about Autoformat, I gather Klaus gave up trying to make
> this work multilingually ...
>
> BUT!
>
> I tried to adapt all this to work for single quote characters (') as well
> and immediately got stuck.
> Find what: '<([!']@)'([ .;,\!\?:\)\]/^13^11^2^5])
>
> ... doesn't find anything at all, when I try it! Why not, and what's the
> workaround?

It doesn't work because the character following a single quote isn't recognized as the beginning of
a word, even if it looks like it to you. If you remove the < character from the Find string, it
works -- until your text contains a contraction, a possessive form, or any other use of a
single-quote/apostrophe. Then it screws up big time. I'll think about a workaround, but I don't see
anything immediately. (You might play with adding a space at the start of the Find string.)

Klaus Linke

unread,
Apr 2, 2002, 8:55:09 PM4/2/02
to
Hi Jay, hi worthy Dave,

Glad Jay jumped in... and he got a bad deal that he managed admirably,
because analysing some wildcard search is much harder than writing it
down IMO.

To proove that, let's build the expression from scratch once more. Of
course I am cheating here, because most of the time you just put
together small expressions and test them on some sample text until you
find something that works, and most of the rationalization comes
afterwards <g>

The easiest and sloppiest way would have been to replace all quotes
that appear at the start of some word with an opening quote, and all
the rest with closing quotes:
Find what: "<(?)
Replace with: ^0147\1
Find what: "
Replace with: ^0148
This would work about as good as AutoCorrect or AutoFormat.

The idea now is to change as many straight quotes as possible to smart
quotes, and leave the rest (unmatched quotes, foot-signs) as straight
quotes.

So the next step is to match proper pairs of quotes only:
Find what: "<(*)>"
Replace with: ^0147\1^0148

This excludes widowed closing quotes: Only those closing quotes that
follow some opening quote are matched.
But widowed opening quotes still makes problems. All text from a
widowed opening quote to the next closing quote of a quote further
down would be matched.
Therefore we disallow all quotes in the matched text:


Find what: "<([!"]@)>"

Replace with: ^0147\1^0148

And now comes the problem that Dave discovered: Closing quotes can not
only appear at the end of words, but also after punctuation.
We cannot express "or" in a Word wildcard search ("either end of word
or punctuation").
Fortunately, almost all characters that can appear *after* a closing
quote don't usually appear after an opening quote, so I used that fact
instead:


Find what: "<([!"]@)"([ .;,\!\?:\)\]/^13^11^2^5])

Replace with: ^0147\1^0148\2

The list of characters that can appear after a closing quote includes
spaces and punctuation; ^2 and ^5 are the codes for foot-/endnotes and
comments, ^11 is a manual line break.

As to single quote characters ('), I share Jay's opinion that other
apostrophes will make it very difficult to find matching quotes
automatically; you would probably need a grammar checker to do a good
job.
You could try to fix contractions like "I'd" or "mustn't" beforehand:
Find what: ([a-zA-Z])'([a-zA-Z])
Replace with: \1^0146\2
but possessive forms and other apostrophes would still make problems.

If you still want to try it, I would change the sequence (instead of
removing the word anchor <):


Find what: <'([!']@)'>

It seems that Word counts single quotes as belonging to the word --
you get accustomed to surprises like this one if you work with
wildcard searches ;-)

BTW, the find/replace for "quote continuation paragraphs" won't work
well if there is more than one of them. Perhaps it would be acceptable
to replace all ^p" with ^p^0147 ?

Greetings, Klaus


Dave Rado wrote:
> > BUT!
> >
> > I tried to adapt all this to work for single quote characters (')
as well
> > and immediately got stuck.
> > Find what: '<([!']@)'([ .;,\!\?:\)\]/^13^11^2^5])
> >
> > ... doesn't find anything at all, when I try it! Why not, and
what's the
> > workaround?
>

Dave Rado

unread,
Apr 6, 2002, 9:17:27 AM4/6/02
to
Hi Klaus

Thanks for your lucid explanation, and for all your help (and Jay's too). :-)

I agree about replacing ^p" with ^p^0147 for the continuation quotes; and
I've given up with single quotes and, for them, have gone back to my MsgBox
idea. FWIW my code currently looks like this:
______________

Sub CreateREALLYSmartQuotes()

'Converts single and double quotes to smart quotes,
'except n the case of the Macro Text style, where it does the reverse;
'and in the case of inch and foot signs, which it converts to proper Unicode
'inch and foot signs.

Dim SmartQuoteSetting As Boolean, HiddenSetting As Boolean, _
ShowAllSetting As Boolean, oDoc As Document, Button As Long

Set oDoc = ActiveDocument
SmartQuoteSetting = Options.AutoFormatAsYouTypeReplaceQuotes
HiddenSetting = oDoc.Windows(1).View.ShowHiddenText
ShowAllSetting = oDoc.Windows(1).View.ShowAll
Options.AutoFormatAsYouTypeReplaceQuotes = False

Application.ScreenUpdating = False

With Selection.Find

.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False

.MatchWildcards = False


.MatchSoundsLike = False
.MatchAllWordForms = False

'FIrst replace smart quotes with keyboard quotes
.Text = """"
.Replacement.Text = """"
.Execute Replace:=wdReplaceAll

.Text = "'"
.Replacement.Text = "'"
.Execute Replace:=wdReplaceAll

'Hide the Macro Text style so its quotes remain keyboard quotes
oDoc.Styles(wdStyleMacroText).Font.Hidden = True
oDoc.Windows(1).View.ShowHiddenText = False
oDoc.Windows(1).View.ShowAll = False

'Replace any single quotes that are meant to be foot signs
'checking with user before replacing
.Text = "([0-9])'"
.Replacement.Text = ""
.Wrap = wdFindContinue
.MatchWildcards = True
Do While .Execute
Application.ScreenUpdating = True
Application.ScreenRefresh
Button = MsgBox("Change this quote to a foot sign?" & vbCr & vbCr & _


"(If you select 'No', it will be converted to a SmartQuote instead)", vbYesNo)
If Button = vbYes Then

.Replacement.Text = "\1" & ChrW(8242)
.Execute Replace:=wdReplaceOne
End If
Application.ScreenUpdating = False
Selection.Collapse wdCollapseEnd
Loop

'Now replace keyboard double quotes in such a way that
'inch signs are left alone (so no need to check with user)
.Text = """<([!""]@)""([ .;,\!\?:\)\]/^13^11^2^5])"
.Replacement.Text = "^0147\1^0148\2"
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll

'Now replace continuation double quotes with SmartQuotes
.MatchWildcards = False
.Wrap = wdFindContinue
.Text = "^p"""
.Replacement.Text = "^p^0147"
.Execute Replace:=wdReplaceAll

.Wrap = wdFindContinue
.Text = "^l"""
.Replacement.Text = "^l^0147"
.Execute Replace:=wdReplaceAll

'Replace any double quotes that are meant to be inch signs
'with Unicode inch signs (no need to check with user)
.MatchWildcards = True
.Wrap = wdFindContinue


.Text = "([0-9])"""

.Replacement.Text = "\1" & ChrW(8243)

.Execute Replace:=wdReplaceAll

'Replace all remaining single quotes with smartquotes
Options.AutoFormatAsYouTypeReplaceQuotes = True
.MatchWildcards = False
.Wrap = wdFindContinue
.Text = "'"
.Replacement.Text = "'"
.Execute Replace:=wdReplaceAll


.Text = ""
.Replacement.Text = ""
.MatchWildcards = False

End With

oDoc.Styles(wdStyleMacroText).Font.Hidden = False
Options.AutoFormatAsYouTypeReplaceQuotes = SmartQuoteSetting
oDoc.Windows(1).View.ShowHiddenText = HiddenSetting
oDoc.Windows(1).View.ShowAll = ShowAllSetting

Application.ScreenUpdating = True

End Sub
'______________

Regards

Dave


"Klaus Linke" <fotosatz...@t-online.de> wrote in message

news:a8dqo1$a8n$07$1...@news.t-online.com...


Hi Jay, hi worthy Dave,

Glad Jay jumped in... and he got a bad deal that he managed admirably,
because analysing some wildcard search is much harder than writing it
down IMO.

To prove that, let's build the expression from scratch once more. Of

Klaus Linke

unread,
Apr 6, 2002, 3:27:01 PM4/6/02
to
Hi Dave,

Looks good :-)

I'd probably have fixed the quotes first, then replaced all remaining
straight quotes following a number with inch signs automatically. This
would lead to errors if there are inch signs inside quotes
(improbable) or widowed quotes following numbers (also improbable),
but wouldn't make manual intervention necessary for all quotes
following numbers (not so improbable).

Greetings, Klaus

Klaus Linke

unread,
Apr 6, 2002, 4:11:04 PM4/6/02
to
Hi Dave,

Looks good :-)

I'd probably have fixed the quotes first, then replaced all remaining

straight quotes following a number with foot signs automatically.
This would lead to errors if there are foot signs inside quotes


(improbable) or widowed quotes following numbers (also improbable),
but wouldn't make manual intervention necessary for all quotes
following numbers (not so improbable).

Greetings, Klaus

((tried to cancel previous message; sorry if it didn't work!))

Dave Rado

unread,
Apr 8, 2002, 6:48:46 AM4/8/02
to
Hi Klaus and Jay

I'm afraid I've realised rather late in the day that Klaus's brilliant idea
doesn't work with:

"Give me twenty 3" nails - no, make that forty", he said.

... which I suspect is a lot more likely to arise than the variation on that
theme that you mentioned earlier.

I've also decided - maybe I'm being foolhardy - that closing quotes after a
number probably *are* a remote enough possibility to be discounted, after
all.

But I've taken on board Klaus's point about Unicode inch and foot signs
being a good idea, and his hidden text idea; so my current version is a
cross between your two approaches:

Sub CreateREALLYSmartQuotes()

Dim SmartQuoteSetting As Boolean, HiddenSetting As Boolean, _
ShowAllSetting As Boolean, oDoc As Document, Button As Long

' save current setting & force True


Set oDoc = ActiveDocument
SmartQuoteSetting = Options.AutoFormatAsYouTypeReplaceQuotes
HiddenSetting = oDoc.Windows(1).View.ShowHiddenText
ShowAllSetting = oDoc.Windows(1).View.ShowAll
Options.AutoFormatAsYouTypeReplaceQuotes = False

Application.ScreenUpdating = False

' convert all quotes to straight quotes
With Selection.Find


.Format = False
.MatchCase = False
.MatchWholeWord = False

.MatchSoundsLike = False
.MatchAllWordForms = False

.Forward = True
.Wrap = wdFindContinue

.MatchWildcards = False

.Text = Chr(34)
.Replacement.Text = Chr(34)

.Execute Replace:=wdReplaceAll

.Wrap = wdFindContinue
.Text = Chr(39)
.Replacement.Text = Chr(39)
.Execute Replace:=wdReplaceAll

Options.AutoFormatAsYouTypeReplaceQuotes = True

'Hide the Macro Text style so its quotes remain keyboard quotes
oDoc.Styles(wdStyleMacroText).Font.Hidden = True
oDoc.Windows(1).View.ShowHiddenText = False
oDoc.Windows(1).View.ShowAll = False

'Replace all remaining quotes with smartquotes


Options.AutoFormatAsYouTypeReplaceQuotes = True
.MatchWildcards = False

.Wrap = wdFindContinue
.Text = Chr(34)
.Replacement.Text = Chr(34)
.Execute Replace:=wdReplaceAll

.Wrap = wdFindContinue
.Text = Chr(39)
.Replacement.Text = Chr(39)
.Execute Replace:=wdReplaceAll

'Convert quote after number to straight inch or foot signs


.MatchWildcards = True
.Wrap = wdFindContinue

.Text = "([0-9])^0148"


.Replacement.Text = "\1" & ChrW(8243)
.Execute Replace:=wdReplaceAll

.Wrap = wdFindContinue
.Text = "([0-9])^0146"


.Replacement.Text = "\1" & ChrW(8242)

.Execute Replace:=wdReplaceAll

'reset F&R dialog


.Text = ""
.Replacement.Text = ""
.MatchWildcards = False

End With

oDoc.Styles(wdStyleMacroText).Font.Hidden = False
Options.AutoFormatAsYouTypeReplaceQuotes = SmartQuoteSetting
oDoc.Windows(1).View.ShowHiddenText = HiddenSetting
oDoc.Windows(1).View.ShowAll = ShowAllSetting

Application.ScreenUpdating = True

End Sub
'______________

Maybe I'm missing something, but this now seems to me like the least bad
solution. It seems such a shame not to use Klaus's brilliant wildcard
string, but such is life. :-)

Regards

Dave


"Klaus Linke" <fotosatz...@t-online.de> wrote in message

news:a8no98$9hk$06$1...@news.t-online.com...

0 new messages