Thread: [Solved] Remove section 2
View Single Post
 
Old 11-08-2018, 08:56 AM
eduzs eduzs is offline Windows 10 Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default Remove section 2

I need to remove the section 2, merging the document in only one section with a VBA code.

Code:
Sub Rem_Sec()

Dim oSec As Section, x As Integer

For x = 2 To ActiveDocument.Sections.Count
    ActiveDocument.Sections(x).Headers(wdHeaderFooterPrimary).LinkToPrevious = True
Next x

With ActiveDocument.Range.Find
    .Text = "^b"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Execute Replace:=wdReplaceAll
End With

End Sub
But this code causes a blank header in the final document, the first section loose format.

There's any solution to this?

Thanks.
__________________
Backup your original file before doing any modification.
Reply With Quote