Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Replace font format macro (Word 2002)

    A customer had what I thought was a simple problem. She uses arial as her default font, however also wants "curly quotes" in her document. I thought a simple find and replace macro would do the trick, however after recording the macro the font attribute doesn't stick - the code is:

    With Options
    .AutoFormatAsYouTypeReplaceQuotes = True
    End With
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = """"
    .Replacement.Text = """"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    End With

    End With
    Selection.Find.Execute Replace:=wdReplaceAll


    I tried recording a macro which changed the font format and came up with:

    With Selection.Font
    .NameAscii = "Times New Roman"
    .NameOther = "Times New Roman"

    End With

    But I cannot figure out where to put that code in the first macro so it will work properly.

    Any help would be greatly appreciated.

    Cheers

    Karen

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Replace font format macro (Word 2002)

    In Word 2000, the recorder blows it on that one, too. Here are the new lines that I added to make the recorded code work:
    <pre>Sub TNRQuotes()
    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = """"
    .Replacement.Text = """"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Replacement.Font.Name = "Times New Roman"
    .Execute Replace:=wdReplaceAll
    .Replacement.ClearFormatting 'clean up after ourselves
    End With
    End Sub</pre>

    (As a matter of habit, I cleaned up the recorder's use of With...End With, but it should work even if you spell out the fully qualified property and method names.)
    Attached Images Attached Images

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Replace font format macro (Word 2002)

    In Word 2000, this can be done with a simple Find/Replace:
    1. Copy the " to the clipboard.
    2. Go to Tools/AutoCorrect/Autoformat as you type/ & check "replace straight quotes with smart quotes".
    3. Open Find/Replace &
    Find: " (paste from the clipboard)
    Replace: " (just type it in)
    4. Press Replace all. The straight quotes will be replaced with curly quotes.

    Cheers,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •