Code for new page section break adding continuous section break

  • Thread starter jacqueline.fulton
  • Start date
J

jacqueline.fulton

I have a macro which inserts a file at the end of an existing
document. I require a new page section break and the first line of
the code moves the curser to the end of the document then inserts a
new page section break, after that I have code which sets new margins,
two columns, unlinks headers/footers etc. However when I run the
macro the section break it inserts is a continuous break - although
the code says next page. Any ideas anyone?
 
J

Jean-Guy Marcil

I have a macro which inserts a file at the end of an existing
document. I require a new page section break and the first line of
the code moves the curser to the end of the document then inserts a
new page section break, after that I have code which sets new margins,
two columns, unlinks headers/footers etc. However when I run the
macro the section break it inserts is a continuous break - although
the code says next page. Any ideas anyone?

Show us the relevant code you use.
 
J

jacqueline.fulton

Show us the relevant code you use.

Here you are - I added a bit at the end of the macro which goes back
to page set up and sets the section to start on a new page (although
this was already set!) and this seems to fix the problem but I still
don't understand why it would create a continuous break in the first
place. Thanks for your help

Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakNextPage
With Selection.PageSetup
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.25)
.BottomMargin = InchesToPoints(0.25)
.LeftMargin = InchesToPoints(0.4)
.RightMargin = InchesToPoints(0.4)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.2)
.FooterDistance = InchesToPoints(0.3)
.SectionStart = wdSectionNewPage
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, count:=1
Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter. _
LinkToPrevious
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
End If
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, count:=1
Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter. _
LinkToPrevious
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
With Selection.PageSetup.TextColumns
.SetCount NumColumns:=1
.EvenlySpaced = False
.LineBetween = False
End With
Selection.PageSetup.TextColumns.Add Width:=InchesToPoints(3.48),
Spacing:= _
InchesToPoints(0.5), EvenlySpaced:=False
Selection.InsertFile FileName:="F:\jf\toawith.doc", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.TypeBackspace
With Selection.PageSetup
.SectionStart = wdSectionNewPage
End With
End Sub
 
J

Jean-Guy Marcil

Here you are - I added a bit at the end of the macro which goes back
to page set up and sets the section to start on a new page (although
this was already set!) and this seems to fix the problem but I still
don't understand why it would create a continuous break in the first
place. Thanks for your help

<snip>

I believe it has to do with:
Selection.InsertFile FileName:="F:\jf\toawith.doc", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.TypeBackspace

<snip>

When you insert the file after the section break, it brings along the
information from the file, including the section definition. It then
interferes with the previously set section definition.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top