Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Dim MyText As String
   Selection.Font.Name = "Garamond"
 Selection.Font.Size = 12
 Selection.Font.ColorIndex = wdBlack
  MyText = "You don't have to meet deductibles for specific services, but see the chart starting on page 2 for other costs for services this plan covers."
  Selection.TypeText (MyText)
        With ActiveDocument.Content.Find
        .ClearFormatting
        .Font.Bold = False
        With .Replacement
        .ClearFormatting
        .Font.Bold = True
        .Font.Underline = wdUnderlineSingle
        End With
        .Execute FindText:="excluded services", ReplaceWith:="", _
        Format:=True, Replace:=wdReplaceAll
End With

The above coding replacing all the pages in my word document.
Posted
Updated 26-Feb-14 20:07pm
v2

1 solution

The reason is in this line:
VB
.Execute FindText:="excluded services", ReplaceWith:="", _
        Format:=True, Replace:=wdReplaceAll 'should be wdReplaceOne


For further information, please see:
Finding and Replacing Text or Formatting[^]
Forward Property[^]
Find.Execute Method (Word)[^]
wdReplace Enumeration[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900