Replacing french quote

J

John Doue

Hi,

I am trying to have a macro do this:

J’écris en francais dans « le texte »

becomes

J’écris en francais dans «le texte»

that is, the space before and after the quotes is eliminated (French
language being selected for the document, smart quotes activated).

With the following sequence:
___________
With Selection.Find
.Text = "^0171 "
.Replacement.Text = "^0171"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

With Selection.Find
.Text = " ^0187"
.Replacement.Text = "^0187"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
____________

I get:

J’écris en francais dans “le texte”; those quotes being curly quotes
(they do not show on this post).

How can I prevent this from happening?

Thanks a lot
 
T

Tony Jollans

Easiest way is to switch off the smart quotes option and restore it
afterwards ...

Dim optsave As Boolean
optsave = Options.AutoFormatAsYouTypeReplaceQuotes
Options.AutoFormatAsYouTypeReplaceQuotes = False

' Your replace code as was

Options.AutoFormatAsYouTypeReplaceQuotes = optsave
 
J

John Doue

Tony said:
Easiest way is to switch off the smart quotes option and restore it
afterwards ...

Dim optsave As Boolean
optsave = Options.AutoFormatAsYouTypeReplaceQuotes
Options.AutoFormatAsYouTypeReplaceQuotes = False

' Your replace code as was

Options.AutoFormatAsYouTypeReplaceQuotes = optsave
Thanks Tony, I am very grateful to you.
Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top