Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 11-08-2018, 08:56 AM
eduzs eduzs is offline Windows 10 Office 2010 32bit
Competent Performer
 
Join Date: May 2017
Posts: 102
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
  #2  
Old 11-08-2018, 01:34 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 18,616
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

See: http://www.msofficeforums.com/word/8...html#post20227
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 11-08-2018, 03:07 PM
eduzs eduzs is offline Windows 10 Office 2010 32bit
Competent Performer
 
Join Date: May 2017
Posts: 102
eduzs is on a distinguished road
Default

Works fine, thanks.
__________________
Backup your original file before doing any modification.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot remove watermark after section break DLM Word 2 06-12-2018 09:14 AM
Remove Section break Anitha Word 3 12-21-2017 06:00 AM
How do I remove a section mickapoo Word 11 01-26-2016 06:58 PM
section page numbers reverting to following on from previous section after generating index cloudtrapezer Word 1 06-25-2015 01:16 AM
Remove unwanted Page in a Section Break JacobReef Word 1 06-10-2012 07:04 AM


All times are GMT -7. The time now is 05:12 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft