Microsoft Office Forums Remove section 2

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-08-2018, 08:56 AM
eduzs eduzs is offline Remove section 2 Windows 10 Remove section 2 Office 2010 32bit
Competent Performer
Remove section 2
 
Join Date: May 2017
Posts: 170
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, test in a throwaway copy of your file.
Reply With Quote
  #2  
Old 11-08-2018, 01:34 PM
macropod's Avatar
macropod macropod is offline Remove section 2 Windows 7 64bit Remove section 2 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,544
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: https://www.msofficeforums.com/word/...html#post20227
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 11-08-2018, 03:07 PM
eduzs eduzs is offline Remove section 2 Windows 10 Remove section 2 Office 2010 32bit
Competent Performer
Remove section 2
 
Join Date: May 2017
Posts: 170
eduzs is on a distinguished road
Default

Works fine, thanks.
__________________
Backup your original file before doing any modification, test in a throwaway copy of your file.
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
Remove section 2 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 section 2 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 07:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft