Forum Discussion

mparento's avatar
mparento
Copper Contributor
May 24, 2022
Solved

Use style to add quotation marks

Hi, I use a character style to highlight some special expressions in my document. Now I want to have quotation marks around these expressions. One convenient way to do it would be to ask the style to add the quotation marks. Is that possible?

  • mparento While you cannot include the quotation marks as part of the style, using a macro such as the following, you could have the style specified in the macro applied to the selected text and have quotation marks inserted before and after it

    Set rng = Selection.Range
    With rng
        .Style = "Strong"
        .InsertBefore Chr(34)
        .InsertAfter Chr(34)
    End With
    

2 Replies

  • mparento While you cannot include the quotation marks as part of the style, using a macro such as the following, you could have the style specified in the macro applied to the selected text and have quotation marks inserted before and after it

    Set rng = Selection.Range
    With rng
        .Style = "Strong"
        .InsertBefore Chr(34)
        .InsertAfter Chr(34)
    End With
    
    • mparento's avatar
      mparento
      Copper Contributor

      Thanks Doug for the good idea! I was hoping to do it with the style itself. That way, if I change my mind, I could modify the style and update the whole document. With the macro, I assume that I would have to run it on each occurrence to add/remove the quotation marks. That being said, I may find you suggestion very helpful in other situations.

       

      Addendum: thinking about it a bit more, I may use your suggestion in the present case. It would make it easier to add the quotation marks. Thanks again!

Resources