2

Hello Friends I have a problem with Quotation marks, so my problem is:

I have a word document (about 100 pages) and want to change quotation marks with (Find and replace), but word can't understand what I need.. here is my example....

"Test Word" you see the quotation marks I want to change them with „Test Word“ (This is the Quotation mark which used In Georgian Language).. Can you help to overcome this problem... (I also tried to use codes like ^0132) but the result is the same.

Thank you In Advanced!

ULTRAMAX
  • 101
  • 1
  • 17

3 Answers3

2

It's easy, open the document and run the following macro:

Sub TestFormatQuotes()

    Selection.WholeStory
    Selection.LanguageID = wdGeorgian
    Selection.Range.AutoFormat

End Sub

This will select the whole document, set the language to Georgian and by running AutoFormat the quotes will automagically be replaced by the lower left and upper right quotes.

You can do this manually, by adding the AutoFormat button to the Quick Access Toolbar using File-Options-Quick Access Toolbar, and select "Commands not in the Ribbon" on the left list. If your AutoFormat settings are right (check the options on the AutoFormat dialog, AutoFormat Tab, Replace, "Straight Quotes" to "Smart Quotes" option enabled) this will automagically replace all the straight quotes.

Maarten van Stam
  • 1,901
  • 1
  • 11
  • 16
  • Thank you very much for your reply, but this don't worked for me.. It gives me “” Quotes, but I need „“ (Double Low-9 Quotation Mark and Double Left Quotation Mark). – ULTRAMAX Oct 21 '16 at 11:00
  • 1
    That is depending on the language used. Did you try manually or using my code? If you tried manually you first need to select the whole text and set the Proofing Language to the language that is using the lower left double quotes nad high right double quotes. I also found that if your document already has the 'smart quotes' it does not repeat the action. So you might need to replace the “ with " again before AutoFormat. – Maarten van Stam Oct 21 '16 at 12:56
  • 1
    I added an answer here showing you how to reset the quotes first. Check that out. – Maarten van Stam Oct 21 '16 at 13:34
2

Here is an example with the option to fully restore the straight quotes before replaceing using AutoFormat. I tested this on your question text above and worked with me.

Sub testquotes()

    Selection.WholeStory

    Dim ReplaceQuotes As Boolean
    ReplaceQuotes = Application.Options.AutoFormatReplaceQuotes = False

    Dim ReplaceQuotesAsYouType As Boolean
    ReplaceQuotesAsYouType = Application.Options.AutoFormatAsYouTypeReplaceQuotes = False

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    ' Alt-0132

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

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    ' Alt-0147

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

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    ' Alt-0148

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

'---Comment This part to revert to straight quotes

    Application.Options.AutoFormatReplaceQuotes = True
    Application.Options.AutoFormatAsYouTypeReplaceQuotes = True

    Selection.LanguageID = wdGeorgian
    Selection.Range.AutoFormat

'---Comment This part to revert to straight quotes

    Application.Options.AutoFormatReplaceQuotes = ReplaceQuotes
    Application.Options.AutoFormatAsYouTypeReplaceQuotes = ReplaceQuotesAsYouType

End Sub
Maarten van Stam
  • 1,901
  • 1
  • 11
  • 16
  • Perfect Worked! Greatest Thanks – ULTRAMAX Oct 24 '16 at 16:25
  • I tested this (for replacing German quotation marks with French ones, in French text). It did indeed the swapping of quotation marks quite well. However, each time I run this, it ruins my meticulously made layouts, as it deletes empty paragraphs (paragraphs consisting only of a paragraph end mark but no text in it). This happens on execution of the "Selection.Range.AutoFormat" line. It obviously searches for pairs of paragraph marks and replaces them with only one. Is there a way to stop this? - My empty paragraphs are there for a reason, not just for lack of care. – Christian Geiselmann Mar 16 '23 at 21:40
0

I experimented with Maarten's solution (see above) and found it good but for the problem that the "AutoFormat" command does silly tricks with empty paragraphs in the document - removing some of them, which is not always what you might want.

Therefore, here is an alternative solution for replacing quotation marks "style Language A" with quotation marks "style language B". It does not touch the text in other unwanted ways.

The code as it is is for swapping German with French quotation marks. You can adjust this to other pairs of languages using the respective characters

Sub ReplaceQuotmarks_DEtoFR()

'Procedure to replace German quotation marks with French ones

'Quotation marks used here are:
  ' German:  Chr(132)  Chr(147) - curvy bottom-top style
  ' French:  Chr(171)  Chr(187) - Guillements, <<  >>
  ' Chr(160) is the non-breaking space

'Definitions
   Dim strFind1 As String
   Dim strReplace1 As String
   Dim strFind2 As String
   Dim strReplace2 As String

'Fill variables with values
   strFind1 = Chr(132) ' German quote start
   strFind2 = Chr(147) ' German quote end
   strReplace1 = Chr(171) ' Opening Guillemet
   strReplace2 = Chr(187) ' Closing Guillemet

'Alternative replacement: with non-breaking space between the Word and the    French quotation marks. Disable it by outcommenting if you do not want to us this.
   strReplace1 = Chr(171) & Chr(160)  ' Guillement & Space
   strReplace2 = Chr(160) & Chr(187)  ' Space and Guillemet

    
'Setting the language
     Selection.WholeStory
     Selection.LanguageID = wdFrench
     'You may define other languages here, e.g. wdGeorgian, wdSpanish, etc.

'Standard replacement procedure throughout the story
    Selection.Find.ClearFormatting
        With Selection.Find
            .text = strFind1
            .Replacement.text = strReplace1
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchKashida = False
            .MatchDiacritics = False
            .MatchAlefHamza = False
            .MatchControl = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
    
    Selection.Find.ClearFormatting
        With Selection.Find
            .text = strFind2
            .Replacement.text = strReplace2
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = True
            .MatchWholeWord = False
            .MatchKashida = False
            .MatchDiacritics = False
            .MatchAlefHamza = False
            .MatchControl = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue

End Sub