Consulting

Results 1 to 3 of 3

Thread: VBA for replace Font with specific Text

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Apr 2021
    Location
    Rajasthan
    Posts
    4
    Location

    VBA for replace Font with specific Text

    Hi,
    I want to replace specific text font name to other font name. I am trying to write a macro for it. but font name not working here. please help and give a suggestion for it. sorry for bad grammer.

    Sub ReplaceTextWithFormatting()
         
        For Each myStoryRange In ActiveDocument.StoryRanges
            With myStoryRange.Find
            
                .ClearFormatting
                .Text = "wiki"
                .Font.Name = "Arial"
                .Replacement.ClearFormatting
                .Replacement.Text = "Romil"
                .Wrap = wdFindContinue
                .MatchCase = True
                .MatchWholeWord = True
                .ClearFormatting
                .Replacement.Font.Name = "Kokila"
                .Replacement.Font.Bold = True
                .Replacement.Font.Size = 18
                .Replacement.Font.Subscript = True
                .Replacement.Font.Color = RGB(0, 0, 255)
                .Execute Replace:=wdReplaceAll
         
            End With
         
        Next myStoryRange
         
    End Sub
    Last edited by macropod; 04-22-2021 at 02:25 PM. Reason: Added code tags

Tags for this Thread

Posting Permissions

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