0

I am trying to use a Word macro to find and replace some text. Part of my original text is in italics (Our Notebook), and I want the replacement text to instead enclose those italicized words in quotation marks ("Our Notebook") and remove the italics. My 'bad' code is show below. Is there a simple fix for this?

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
    .Text = "From Our Notebook"
    .Replacement.Text = "From "Our NoteBook""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
End With
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
  • 1
    Possible duplicate of [How do I put double quotes in a string in vba?](http://stackoverflow.com/questions/9024724/how-do-i-put-double-quotes-in-a-string-in-vba) – Orphid Feb 12 '17 at 13:29
  • Thanks, Orphid. I looked that other post up, but either I didn't understand their recommended solution, or it didn't work for my case. – user2216370 Feb 13 '17 at 01:38
  • The usage of `Chr(34)` would look like this: `.Replacement.Text = "From " & Chr(34) & "Out NoteBook" & Chr(34)`. – Zev Spitz Feb 17 '17 at 07:59
  • @Orphid VTC as duplicate. – Zev Spitz Feb 17 '17 at 08:00

1 Answers1

0

I believe I have figured this out. The solution is to use two double quotation marks to indicate an output of single double quotation mark. Since these have to go inside a set of double quotation marks (e.g., .Replacement.Text = "From ""Our NoteBook"""), you end up with a lot of quotation marks!