Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

Working with Stylized Quotes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George Thompson - 16 Aug 2005 17:42 GMT
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
Chuck Henrich - 17 Aug 2005 12:07 GMT
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

Signature

Chuck Henrich
www.ProductivityApps.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.