escape character, ", smart quote

J

John Smith

I'm using find and replace to modify HTML files. There is a
problem. HTML files contain many double quotation marks. Thus,
they need an escape character. If I use a double quotation mark as
the escape character, the resulting file doesn't work because all
the double quotation marks have been changed to smart quote.

Anyway to tell, by code, Word to stick to simple quotation marks?
Thanks.

======================================
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Save money on your prescription drugs"
.Replacement.Text = "Save <span class=""style7"">money</span>
on your prescription drugs"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll

====================================
 
J

Jay Freedman

The straight quote marks are being changed to smart quotes because that option is turned on in the AutoFormat As You Type dialog.

In your macro you can temporarily turn off that option, do your replacements, and then restore the original setting (whether it was on or off):

Sub ReplaceQuotes()
Dim optQuotes As Boolean

optQuotes = Options.AutoFormatAsYouTypeReplaceQuotes
Options.AutoFormatAsYouTypeReplaceQuotes = False

' do your replacement here

Options.AutoFormatAsYouTypeReplaceQuotes = optQuotes
End Sub
 
J

John Smith

Thank you.

Works like a charm.

Jay said:
The straight quote marks are being changed to smart quotes because that option is turned on in the AutoFormat As You Type dialog.

In your macro you can temporarily turn off that option, do your replacements, and then restore the original setting (whether it was on or off):

Sub ReplaceQuotes()
Dim optQuotes As Boolean

optQuotes = Options.AutoFormatAsYouTypeReplaceQuotes
Options.AutoFormatAsYouTypeReplaceQuotes = False

' do your replacement here

Options.AutoFormatAsYouTypeReplaceQuotes = optQuotes
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
 

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