I tried this but doesn't work.
StyleName = "Heading 1"
If wdDocTgt.Styles(StyleName).ParagraphFormat.PageBre akBefore Then
MsgBox StyleName & " has 'Page break before' set. Run aborted"
Exit Sub
End If
Set wdDocTgt = ActiveDocument
Selection.HomeKey unit:=wdStory
With Selection.Find
.ClearFormatting
.Style = wdDocTgt.Styles(StyleName)
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
Do While Selection.Find.Execute
If Asc(Selection.Range.Characters(1)) = 12 Then
Selection.MoveStart unit:=wdCharacter, Count:=1
End If
Selection.Start = Selection.End
Loop
|