Insert and Delete Pages
-
- 5StarLounger
- Posts: 737
- Joined: 24 Aug 2017, 07:43
Insert and Delete Pages
Dear Community,
Is there any way to delete the pages without using back space or selecting the content from page top to bottom and then delete. Because if i use this method alignment of the other pages also changed. How to insert the specific pages from one word document to other document without any changes in alignment in both of the documents. For example i want to delete the second page of this attachment8 and insert the two pages from client satisfaction form. if i copy the client satisfaction form to attachment file alignment is changing. How to do this without any alignment changes.
Is there any way to delete the pages without using back space or selecting the content from page top to bottom and then delete. Because if i use this method alignment of the other pages also changed. How to insert the specific pages from one word document to other document without any changes in alignment in both of the documents. For example i want to delete the second page of this attachment8 and insert the two pages from client satisfaction form. if i copy the client satisfaction form to attachment file alignment is changing. How to do this without any alignment changes.
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Insert and Delete Pages
I'll look at your question this evening (European time).
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 737
- Joined: 24 Aug 2017, 07:43
Re: Insert and Delete Pages
Dear sir,
Sir thank you so much sir. When you will be free teach me sir. But sir i am wondering sir. Because its little bit difficult for me if i need to edit existing pages with header and footer especially if i want to delete the pages and inserting the pages. For instance i am working with one word document it have 4 pages. i want to delete the 2nd page if i put a cursor on the top of the 2nd page and press delete button the content of 3rd pages also moving upward direction. So the paragraph or line alignment will be changed. so again i need fix all the pages. This is ok for small number of pages. But what to do sir if i want to work with more than 100pages. I need to check every pages and if i need to make alignment i have to do for all pages. Kindly teach me sir.
Sir thank you so much sir. When you will be free teach me sir. But sir i am wondering sir. Because its little bit difficult for me if i need to edit existing pages with header and footer especially if i want to delete the pages and inserting the pages. For instance i am working with one word document it have 4 pages. i want to delete the 2nd page if i put a cursor on the top of the 2nd page and press delete button the content of 3rd pages also moving upward direction. So the paragraph or line alignment will be changed. so again i need fix all the pages. This is ok for small number of pages. But what to do sir if i want to work with more than 100pages. I need to check every pages and if i need to make alignment i have to do for all pages. Kindly teach me sir.
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Insert and Delete Pages
The problem you have when deleting Section breaks is that they're what all the page layout specs, including headers & footers, for the Section are attached to. The following macro preserves the page layout across multiple deleted Section breaks. All common page layout issues (margins, page orientation, text columns, headers & footers) are addressed.
Code: Select all
Sub MergeSections()
Application.ScreenUpdating = False
Dim sPageHght As Single, sPageWdth As Single
Dim sHeaderDist As Single, sFooterDist As Single
Dim sTMargin As Single, sBMargin As Single
Dim sLMargin As Single, sRMargin As Single
Dim sGutter As Single, sGutterPos As Single
Dim lPaperSize As Long, lGutterStyle As Long
Dim lMirrorMargins As Long, lVerticalAlignment As Long
Dim lScnStart As Long, lScnDir As Long
Dim lOddEvenHdFt As Long, lDiffFirstHdFt As Long
Dim bTwoPagesOnOne As Boolean, bBkFldPrnt As Boolean
Dim bBkFldPrnShts As Boolean, bBkFldRevPrnt As Boolean
Dim bOrientation As Boolean, oHdFt As HeaderFooter
Dim Sctn1 As Section, Sctn2 As Section
With Selection
If .Sections.Count = 1 Then
MsgBox "Selection does not span a Section break", vbExclamation
Exit Sub
End If
Set Sctn1 = .Sections.First: Set Sctn2 = .Sections.Last
With Sctn1.PageSetup
lPaperSize = .PaperSize
lGutterStyle = .GutterStyle
bOrientation = .Orientation
lMirrorMargins = .MirrorMargins
lScnStart = .SectionStart
lScnDir = .SectionDirection
lOddEvenHdFt = .OddAndEvenPagesHeaderFooter
lDiffFirstHdFt = .DifferentFirstPageHeaderFooter
lVerticalAlignment = .VerticalAlignment
sPageHght = .PageHeight
sPageWdth = .PageWidth
sTMargin = .TopMargin
sBMargin = .BottomMargin
sLMargin = .LeftMargin
sRMargin = .RightMargin
sGutter = .Gutter
sGutterPos = .GutterPos
sHeaderDist = .HeaderDistance
sFooterDist = .FooterDistance
bTwoPagesOnOne = .TwoPagesOnOne
bBkFldPrnt = .BookFoldPrinting
bBkFldPrnShts = .BookFoldPrintingSheets
bBkFldRevPrnt = .BookFoldRevPrinting
End With
With Sctn2.PageSetup
.GutterStyle = lGutterStyle
.MirrorMargins = lMirrorMargins
.SectionStart = lScnStart
.SectionDirection = lScnDir
.OddAndEvenPagesHeaderFooter = lOddEvenHdFt
.DifferentFirstPageHeaderFooter = lDiffFirstHdFt
.VerticalAlignment = lVerticalAlignment
.PageHeight = sPageHght
.PageWidth = sPageWdth
.TopMargin = sTMargin
.BottomMargin = sBMargin
.LeftMargin = sLMargin
.RightMargin = sRMargin
.Gutter = sGutter
.GutterPos = sGutterPos
.HeaderDistance = sHeaderDist
.FooterDistance = sFooterDist
.TwoPagesOnOne = bTwoPagesOnOne
.BookFoldPrinting = bBkFldPrnt
.BookFoldPrintingSheets = bBkFldPrnShts
.BookFoldRevPrinting = bBkFldRevPrnt
.PaperSize = lPaperSize
.Orientation = bOrientation
End With
With Sctn2
For Each oHdFt In .Footers
oHdFt.LinkToPrevious = Sctn1.Footers(oHdFt.Index).LinkToPrevious
If oHdFt.LinkToPrevious = False Then
Sctn1.Headers(oHdFt.Index).Range.Copy
oHdFt.Range.Paste
End If
Next
For Each oHdFt In .Headers
oHdFt.LinkToPrevious = Sctn1.Headers(oHdFt.Index).LinkToPrevious
If oHdFt.LinkToPrevious = False Then
Sctn1.Headers(oHdFt.Index).Range.Copy
oHdFt.Range.Paste
End If
Next
End With
While .Sections.Count > 1
.Sections.First.Range.Characters.Last.Delete
Wend
Set Sctn1 = Nothing: Set Sctn2 = Nothing
End With
Application.ScreenUpdating = True
End Sub
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- GoldLounger
- Posts: 2599
- Joined: 24 Jan 2010, 15:26
- Location: Olympia, WA
Re: Insert and Delete Pages
For starters the alignment issue just may start because the file contains space, space, space, space, space, space, to format the text. All of the space, space, space, needs to be replaced with correct tabbing. The tabs need to be defined and set to right position and not use tab, tab, tab.
If you were to turn on the "Nonprinting characters" you will see all of these spaces, plus all of the other minor issues.
If you were to turn on the "Nonprinting characters" you will see all of these spaces, plus all of the other minor issues.
I am so far behind, I think I am First
Genealogy....confusing the dead and annoying the living
Genealogy....confusing the dead and annoying the living
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Insert and Delete Pages
There's no evidence of that being the underlying issue in either of the attachments.DaveA wrote:For starters the alignment issue just may start because the file contains space, space, space, space, space, space, to format the text.
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 5StarLounger
- Posts: 737
- Joined: 24 Aug 2017, 07:43
Re: Insert and Delete Pages
Dear All,
Good morning to all, I searched about this topic in online. Someone said that if we want to delete the page exactly we can use goto option and \page then entire page will be selected then if we delete the page entire page will be deleted. I tried this method but header is not deleted. Then i try to delete the non printable character of the page. But i couldn't delete that character. i Couldn't use section break. because if i try to do section break it create 3rd page. one more thing is if use paste special option keep formatting source alignment also changed. Could you please help me how to do this.
Good morning to all, I searched about this topic in online. Someone said that if we want to delete the page exactly we can use goto option and \page then entire page will be selected then if we delete the page entire page will be deleted. I tried this method but header is not deleted. Then i try to delete the non printable character of the page. But i couldn't delete that character. i Couldn't use section break. because if i try to do section break it create 3rd page. one more thing is if use paste special option keep formatting source alignment also changed. Could you please help me how to do this.
You do not have the required permissions to view the files attached to this post.
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Insert and Delete Pages
The underlying issue with your documents is their illogical use of Section breaks (especially Continuous Section beaks) and the way those compromise attempts to combine parts of one document with part of another. I do have to agree with Dave, though, that your use of spaces, etc. to manage the layout is far from optimal. You'll find things much easier to manage if you fix these things. See attached.
You do not have the required permissions to view the files attached to this post.
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 5StarLounger
- Posts: 737
- Joined: 24 Aug 2017, 07:43
Re: Insert and Delete Pages
Dear sir,macropod wrote: to manage the layout is far from optimal. You'll find things much easier to manage if you fix these things. See attached.
Thank you sir but I don't understand sir what you mean. You mean this kind of issues we can not rectify. In your attachment i couldn't see any changes sir. Now what i want to do sir.
-
- BronzeLounger
- Posts: 1267
- Joined: 01 May 2016, 09:58
Re: Insert and Delete Pages
HI ,
in this link explained how to move one page or multiple pages from one-word file to another one ... hope this help
https://www.extendoffice.com/documents/ ... other.html
and the other quick way is :
1- in the destination file, insert page break where you want to insert the pages ...
2- do the same alignment to the inserted page same as the source file
3- copy and paste the pages
regards
in this link explained how to move one page or multiple pages from one-word file to another one ... hope this help
https://www.extendoffice.com/documents/ ... other.html
and the other quick way is :
1- in the destination file, insert page break where you want to insert the pages ...
2- do the same alignment to the inserted page same as the source file
3- copy and paste the pages
regards
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Insert and Delete Pages
If you compare my attachments against those in your first post, you will see they are indeed structured quite differently. Each has one less Section break than you had (both being unnecessary Continuous Section breaks) and uses tabs & tab-stops to manage the checkbox layout. Having got rid of those unnecessary Continuous Section breaks, the documents are now much easier to merge.BOOBALAN.V wrote:In your attachment i couldn't see any changes sir. Now what i want to do sir.
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Insert and Delete Pages
Neither of those approaches deals adequately with documents that have different page layouts, as is the case in this thread. Using page breaks, in particular, is singularly ineffective in this case.siamandm wrote:in this link explained how to move one page or multiple pages from one-word file to another one
...
and the other quick way is
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Insert and Delete Pages
Boobalan,
Moving pages between documents that have different page layouts, headers/footers etc. will always be a lot of work, because if you copy/paste a page with its page layout, you may mess up the layout of the target document, and if you copy/paste without it, the pasted page may look very different from the original. So whichever way you use, you'll have to perform lots of repairs. There is no easy solution in my opinion, even with macropod's improved layout, sorry.
Moving pages between documents that have different page layouts, headers/footers etc. will always be a lot of work, because if you copy/paste a page with its page layout, you may mess up the layout of the target document, and if you copy/paste without it, the pasted page may look very different from the original. So whichever way you use, you'll have to perform lots of repairs. There is no easy solution in my opinion, even with macropod's improved layout, sorry.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 737
- Joined: 24 Aug 2017, 07:43
Re: Insert and Delete Pages
Dear sir,
Good evening sir. You are right sir. I tried even kutools. But that also not working in my case. Actually i did my work with PDF tool adobe acrobat without compromising my document alignment. Inserting pages and deleting pages without any problem. But sir i was really wondering i am going to get a proper answer for this case. MS Word should not be like this. Why sir they didn't update regarding this issues. Everybody going to add some pages or delete some pages from one document to other. Why they didn't consider this kind of issues. Is this really good for documentation. Anyway thank you so much guys you all. Especially Mr.macropd sir. Sir really thank you so much sir for your coding. Because you have spent your valuable time for me. I hope this would be helpful for everyone i mean your VBA code. Once again thank you all.
Good evening sir. You are right sir. I tried even kutools. But that also not working in my case. Actually i did my work with PDF tool adobe acrobat without compromising my document alignment. Inserting pages and deleting pages without any problem. But sir i was really wondering i am going to get a proper answer for this case. MS Word should not be like this. Why sir they didn't update regarding this issues. Everybody going to add some pages or delete some pages from one document to other. Why they didn't consider this kind of issues. Is this really good for documentation. Anyway thank you so much guys you all. Especially Mr.macropd sir. Sir really thank you so much sir for your coding. Because you have spent your valuable time for me. I hope this would be helpful for everyone i mean your VBA code. Once again thank you all.
-
- 5StarLounger
- Posts: 629
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Insert and Delete Pages
Word and Acrobat work very differently. In Word, text is intended to flow through a document with page breaks being inserted as needed for printing. It generally does not really see pages at all until it is time to print.Actually i did my work with PDF tool adobe acrobat without compromising my document alignment. Inserting pages and deleting pages without any problem. But sir i was really wondering i am going to get a proper answer for this case. MS Word should not be like this. Why sir they didn't update regarding this issues.
You can interfere with this by inserting page breaks, to some extent.
Acrobat is a print emulation that deals more with pages than with text.
MS Word is like this. It always has been and it is likely to remain this way. To change it into a page layout program would change its very nature. It is reasonable to want a program that does what you want, but Word is not that program.MS Word should not be like this. Why sir they didn't update regarding this issues.
MS does have Publisher, which is a part of many Office suites and does allow movement of pages. If Adobe Acrobat is doing what you want, use it. I often use Acrobat when I want to combine things from disparate sources; when I want to move pages around, rather than edit the actual content.
Paul has given you some tools. You need to understand what you are doing when you insert Section breaks. It is far more than a page break. You are adding a fair amount of complexity to your document each time you add a Section break. Each Section break carries a bunch of formatting for that section which you may not even see.
http://www.addbalance.com/usersguide/sections2007.htm
Last edited by Charles Kenyon on 30 Sep 2017, 16:59, edited 1 time in total.
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- 5StarLounger
- Posts: 629
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Insert and Delete Pages
Here is another tool which you could use, if you want to continue using Word for this purpose:
https://wordaddins.com/products/word-to ... d-footers/
You will still need, at least, a rudimentary understanding of how Sections work, though.
When you insert a Section Break in Word, you add the following to your document:
Three headers (even if you see none of them); by default, these will be linked to those in the previous section.
Three footers (even if you see none of them); by default, these will be linked to those in the previous section.
Page margin settings (even if you did not change them).
Column settings (even if you did not change them).
Orientation settings (even if you did not change them).
Page number formatting (even if you did not change it for this section); same as the previous section upon insertion of section break. If you restarted numbering in the previous section, it will restart now.
This is true even if there are two continuous Section Breaks on a single page and you see no headers, footers, or page numbers between those Section Breaks; they are present in your document and can change how subsequent sections behave.
https://wordaddins.com/products/word-to ... d-footers/
You will still need, at least, a rudimentary understanding of how Sections work, though.
When you insert a Section Break in Word, you add the following to your document:
Three headers (even if you see none of them); by default, these will be linked to those in the previous section.
Three footers (even if you see none of them); by default, these will be linked to those in the previous section.
Page margin settings (even if you did not change them).
Column settings (even if you did not change them).
Orientation settings (even if you did not change them).
Page number formatting (even if you did not change it for this section); same as the previous section upon insertion of section break. If you restarted numbering in the previous section, it will restart now.
This is true even if there are two continuous Section Breaks on a single page and you see no headers, footers, or page numbers between those Section Breaks; they are present in your document and can change how subsequent sections behave.
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- 5StarLounger
- Posts: 629
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Insert and Delete Pages
If you plan on continuing to use Word, extensively, you owe it to yourself to learn more about how it works. It is not a typewriter; it is not Acrobat, or any other program. You will save yourself time and frustration.
Basic Concepts of Microsoft Word: http://www.addbalance.com/usersguide/Ba ... tsWord.htm
Basic Concepts of Microsoft Word: http://www.addbalance.com/usersguide/Ba ... tsWord.htm
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Insert and Delete Pages
In post #1 you said:
The code works fine for this particular scenario; making it generic would require a lot more work.
To give you an idea of what's involved in such an exercise, try the following macro. I've written it to work the other way around from what you described, as that's simpler in this particular case! In other words, the macro allows you to insert the first Section from another document (e.g. my Attachment-8A) and before the content of an existing active document (e.g. my attachment Client Satisfaction Survey1A). The result is the same as doing it the way you described except insofar as which document gets modified.BOOBALAN.V wrote:For example i want to delete the second page of this attachment8 and insert the two pages from client satisfaction form.
Code: Select all
Sub ImportDocumentPart()
Application.ScreenUpdating = False
Application.DisplayAlerts = wdAlertsNone
Dim DocSrc As Document, DocTgt As Document
Dim strDocNm As String, Rng As Range, HdFt As HeaderFooter
Set DocTgt = ActiveDocument
strDocNm = DocTgt.FullName
With Dialogs(wdDialogFileOpen)
If .Show = -1 Then
Set DocSrc = Documents.Open(FileName:=.Name, AddToRecentFiles:=False, Visible:=False)
With DocTgt
.Range.Characters.First.InsertBreak Type:=wdSectionBreakNextPage
Set Rng = .Range.Characters.First
With Rng
.InsertBefore vbCr
.Collapse wdCollapseStart
End With
With .Sections(2)
For Each HdFt In .Headers
HdFt.LinkToPrevious = False
Next
For Each HdFt In .Footers
HdFt.LinkToPrevious = False
Next
End With
With .Sections(1)
For Each HdFt In .Headers
With HdFt.Range
If Len(DocSrc.Sections.First.Headers(HdFt.Index).Range.Text) > 1 Then
.FormattedText = DocSrc.Sections.First.Headers(HdFt.Index).Range.FormattedText
.Characters.Last.Delete
Else
.Text = vbNullString
End If
End With
Next
For Each HdFt In .Footers
With HdFt.Range
If Len(DocSrc.Sections.First.Footers(HdFt.Index).Range.Text) > 1 Then
.FormattedText = DocSrc.Sections.First.Footers(HdFt.Index).Range.FormattedText
.Characters.Last.Delete
Else
.Text = vbNullString
End If
End With
Next
Call LayoutTransfer(DocSrc.Range.Characters.First, .Range.Characters.First)
Set Rng = DocSrc.Sections.First.Range
Rng.End = Rng.End - 1
.Range.Characters.First.FormattedText = Rng.FormattedText
End With
End With
DocSrc.Close False
End If
End With
Set Rng = Nothing: Set DocTgt = Nothing: Set DocSrc = Nothing
Application.DisplayAlerts = wdAlertsAll
Application.ScreenUpdating = True
End Sub
Sub LayoutTransfer(RngSrc As Range, RngTgt As Range)
'Page Layout variables
Dim sPageHght As Single, sPageWdth As Single
Dim sHeaderDist As Single, sFooterDist As Single
Dim sTMargin As Single, sBMargin As Single
Dim sLMargin As Single, sRMargin As Single
Dim sGutter As Single, sGutterPos As Single
Dim lPaperSize As Long, lGutterStyle As Long
Dim lMirrorMargins As Long, lVerticalAlignment As Long
Dim lScnStart As Long, lScnDir As Long
Dim lOddEvenHdFt As Long, lDiffFirstHdFt As Long
Dim bTwoPagesOnOne As Boolean, bBkFldPrnt As Boolean
Dim bBkFldPrnShts As Boolean, bBkFldRevPrnt As Boolean
Dim bOrientation As Boolean
'Get Page Setup parameters
With RngSrc.Sections.First.PageSetup
lPaperSize = .PaperSize
lGutterStyle = .GutterStyle
bOrientation = .Orientation
lMirrorMargins = .MirrorMargins
lScnDir = .SectionDirection
lOddEvenHdFt = .OddAndEvenPagesHeaderFooter
lDiffFirstHdFt = .DifferentFirstPageHeaderFooter
lVerticalAlignment = .VerticalAlignment
sPageHght = .PageHeight
sPageWdth = .PageWidth
sTMargin = .TopMargin
sBMargin = .BottomMargin
sLMargin = .LeftMargin
sRMargin = .RightMargin
sGutter = .Gutter
sGutterPos = .GutterPos
sHeaderDist = .HeaderDistance
sFooterDist = .FooterDistance
bTwoPagesOnOne = .TwoPagesOnOne
bBkFldPrnt = .BookFoldPrinting
bBkFldPrnShts = .BookFoldPrintingSheets
bBkFldRevPrnt = .BookFoldRevPrinting
End With
'Set Page Setup parameters
With RngTgt.Sections.First.PageSetup
.GutterStyle = lGutterStyle
.MirrorMargins = lMirrorMargins
.SectionDirection = lScnDir
.OddAndEvenPagesHeaderFooter = lOddEvenHdFt
.DifferentFirstPageHeaderFooter = lDiffFirstHdFt
.VerticalAlignment = lVerticalAlignment
.PageHeight = sPageHght
.PageWidth = sPageWdth
.TopMargin = sTMargin
.BottomMargin = sBMargin
.LeftMargin = sLMargin
.RightMargin = sRMargin
.Gutter = sGutter
.GutterPos = sGutterPos
.HeaderDistance = sHeaderDist
.FooterDistance = sFooterDist
.TwoPagesOnOne = bTwoPagesOnOne
.BookFoldPrinting = bBkFldPrnt
.BookFoldPrintingSheets = bBkFldPrnShts
.BookFoldRevPrinting = bBkFldRevPrnt
.PaperSize = lPaperSize
.Orientation = bOrientation
End With
End Sub
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]