Consulting

Results 1 to 3 of 3

Thread: Solved: Delete Section Breaks

  1. #1
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location

    Solved: Delete Section Breaks

    In the attached sample document, I am unable to do something I am normally able to do: Find and replace section breaks with nothing. I want to get rid of the section breaks.

    This is the recorded code that would normally work:
    [VBA] Sub Macro4()
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = "^b"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    [/VBA]

    Help!!
    ~Anne Troy

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hi Anne
    I don't really understand why replace isn't working there... so maybe you could just loop the find and delete it, if you see what I mean - that does seem to work fine [VBA]Sub Macro4()
    With ActiveDocument.Content.Find
    .ClearFormatting
    .Text = "^b"
    .Forward = True
    Do While .Execute = True
    .Parent.Delete
    Loop
    End With
    End Sub[/VBA]
    K :-)

  3. #3
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Seems to work! Thanks a bunch!!
    ~Anne Troy

Posting Permissions

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