none
Macro to replace the quotation RRS feed

  • Question

  • Hi all~ I'm a freshman in this forum. I have a question.

    Today I copied some articles online to the word, but I found that the quotation wasn't right. It's like: 「Help me!」,but it's the quotation in Chinese and it looks so wield in my article. I want to change it to “Help me!” I want to write a macro to replace all of them in article, but I'm not into this. Could you please help me? Thanks in advance~~


    Sunday, March 3, 2019 10:44 PM

Answers

  • Try this macro:

    Sub FixQuotation()
        With ActiveDocument.Content.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .Execute FindText:=ChrW(12300), ReplaceWith:=Chr(34), Replace:=wdReplaceAll
            .Execute FindText:=ChrW(12301), ReplaceWith:=Chr(34), Replace:=wdReplaceAll
        End With
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Isabella 520 Monday, March 4, 2019 10:40 PM
    Monday, March 4, 2019 9:14 AM

All replies

  • Try this macro:

    Sub FixQuotation()
        With ActiveDocument.Content.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .Execute FindText:=ChrW(12300), ReplaceWith:=Chr(34), Replace:=wdReplaceAll
            .Execute FindText:=ChrW(12301), ReplaceWith:=Chr(34), Replace:=wdReplaceAll
        End With
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Isabella 520 Monday, March 4, 2019 10:40 PM
    Monday, March 4, 2019 9:14 AM
  • Thanks. By the way, it works in English but not in Chinese. Could you please edit it to make it work in Chinese?

    For example,   「我也是醉了」 「草泥马」成了当今的网络热词。

    Thanks a lot~~

    Regards, Isabella


    Monday, March 4, 2019 7:27 PM
  • This is what happens if I run the macro on your Chinese text:

    Before:

    After:

    That looks OK to me. What happens when you run the macro?


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Isabella 520 Monday, March 4, 2019 10:40 PM
    • Unmarked as answer by Isabella 520 Monday, March 4, 2019 10:40 PM
    Monday, March 4, 2019 8:41 PM
  • Sorry, it's my mistake. It works when there is a space between  and「. Thanks a lot! Could you please tell me how it works? I want to learn something from it.
    Monday, March 4, 2019 10:40 PM
  • With ActiveDocument.Content.Find specifies that we want to find/replace text in the entire document.

    The lines

            .ClearFormatting
           
    .Replacement.ClearFormatting

    specify that we don't want to take formatting into account (for example, if you had searched for bold or green text before this).

            .Execute FindText:=ChrW(12300), ReplaceWith:=Chr(34), Replace:=wdReplaceAll

    replaces all occurrences of = ChrW(12300) with " = Chr(34)

            .Execute FindText:=ChrW(12301), ReplaceWith:=Chr(34), Replace:=wdReplaceAll

    does the same for 」=ChrW(12301)


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Wednesday, March 6, 2019 4:35 PM