E
Ebbe
Hey!
I have a document with some textboxes and graphic elements (shapes) in the
header. These shapes is repeated on each page.
But I want to insert some other document in the middle of the document and
preserve the shapes on both sides of this inserted document.
Standing on page 1, I want to insert a page (another document) as page 2.
Page 3 should have the same header/footer as page 1.
Here is what I am doing and what I see:
--------------------------------------------------------------------------------------------------------------------------
Sub InsertDocumentAfterPage()
Dim i As Integer
'---- Standing on page 1
'---- New page 2 gets the same shapes as page x
Selection.InsertBreak Type:=wdSectionBreakNextPage
'---- Cutting the link to page 1
ActiveDocument.Sections(ActiveDocument.Sections.Count).Headers(wdHeaderFooterPrimary).LinkToPrevious
= False
ActiveDocument.Sections(ActiveDocument.Sections.Count).Footers(wdHeaderFooterPrimary).LinkToPrevious
= False
'---- New page 3 gets the same shapes as page 2
Selection.InsertBreak Type:=wdSectionBreakNextPage
'---- Cutting the link to page 2
ActiveDocument.Sections(ActiveDocument.Sections.Count).Headers(wdHeaderFooterPrimary).LinkToPrevious
= False
ActiveDocument.Sections(ActiveDocument.Sections.Count).Footers(wdHeaderFooterPrimary).LinkToPrevious
= False
'---- Trying to delete all shapes in header of page 2 (!!!! but the shapes
is removed on ALL pages !!!!)
i = ActiveDocument.Sections(ActiveDocument.Sections.Count -
1).Headers(wdHeaderFooterPrimary).Shapes.Count
While i > 0
ActiveDocument.Sections(ActiveDocument.Sections.Count -
1).Headers(wdHeaderFooterPrimary).Shapes(i).Delete
i = i - 1
Wend
'---- Moving to end of page 2
Selection.MoveLeft Count:=1
'---- Inserting an other document on page 2
Selection.InsertFile
FileName:="d:\XALKun\Seelen\EG_X2W\SeelenFakHanbet.doc", _
Range:="", ConfirmConversions:=False, Link:=False, _
Attachment:=False
'---- Moving to end of story on page 3
Selection.EndKey Unit:=wdStory
End Sub
I have a document with some textboxes and graphic elements (shapes) in the
header. These shapes is repeated on each page.
But I want to insert some other document in the middle of the document and
preserve the shapes on both sides of this inserted document.
Standing on page 1, I want to insert a page (another document) as page 2.
Page 3 should have the same header/footer as page 1.
Here is what I am doing and what I see:
--------------------------------------------------------------------------------------------------------------------------
Sub InsertDocumentAfterPage()
Dim i As Integer
'---- Standing on page 1
'---- New page 2 gets the same shapes as page x
Selection.InsertBreak Type:=wdSectionBreakNextPage
'---- Cutting the link to page 1
ActiveDocument.Sections(ActiveDocument.Sections.Count).Headers(wdHeaderFooterPrimary).LinkToPrevious
= False
ActiveDocument.Sections(ActiveDocument.Sections.Count).Footers(wdHeaderFooterPrimary).LinkToPrevious
= False
'---- New page 3 gets the same shapes as page 2
Selection.InsertBreak Type:=wdSectionBreakNextPage
'---- Cutting the link to page 2
ActiveDocument.Sections(ActiveDocument.Sections.Count).Headers(wdHeaderFooterPrimary).LinkToPrevious
= False
ActiveDocument.Sections(ActiveDocument.Sections.Count).Footers(wdHeaderFooterPrimary).LinkToPrevious
= False
'---- Trying to delete all shapes in header of page 2 (!!!! but the shapes
is removed on ALL pages !!!!)
i = ActiveDocument.Sections(ActiveDocument.Sections.Count -
1).Headers(wdHeaderFooterPrimary).Shapes.Count
While i > 0
ActiveDocument.Sections(ActiveDocument.Sections.Count -
1).Headers(wdHeaderFooterPrimary).Shapes(i).Delete
i = i - 1
Wend
'---- Moving to end of page 2
Selection.MoveLeft Count:=1
'---- Inserting an other document on page 2
Selection.InsertFile
FileName:="d:\XALKun\Seelen\EG_X2W\SeelenFakHanbet.doc", _
Range:="", ConfirmConversions:=False, Link:=False, _
Attachment:=False
'---- Moving to end of story on page 3
Selection.EndKey Unit:=wdStory
End Sub