Working with Stylized Quotes

G

George Thompson

Hi Everyone,

Does anyone know of a function that will convert Stylized Quotes to a normal
quote?

Here is the application; I am comparing one string to another. In some cases
the strings do not match when they should. The issue is that use of Stylized
Quotes. One string may use a slightly different version of a single quote
causing the string comparison function to fail. I would like to convert all
single quotes to a simple quote for comparing.

Thanks,
George
 
C

Chuck Henrich

The following replaces curly quotes with straight quotes. It changes the
autocorrect option for "smart" quotes to straight quotes, goes through each
storyrange, replaces doulbe and single quotes with themselves, thus setting
them all straight.


Sub StraightenQuotes()

Dim rngStory As Range
Dim strString As String

'Set curly quotes to straight quotes
Options.AutoFormatAsYouTypeReplaceQuotes = False

For Each rngStory In ActiveDocument.StoryRanges
Do Until (rngStory Is Nothing)
If Len(rngStory) > 2 Then
strString = Chr(34) 'double quotes
GoSub FindReplace
strString = Chr(39) 'single quotes
GoSub FindReplace
End If
Set rngStory = rngStory.NextStoryRange
Loop
Next rngStory

Exit Sub

FindReplace:

With rngStory.Find
.Text = strString
.Replacement.Text = strString
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With

Return

End Sub
 

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