inserting section break without header/footer

B

bryan

Programmically I have used insert section break to insert a document.
First page of template has footer/header
What I would like to do for a project is to insert a document that
has 2 colums with no footer/header.
How can I turn off the footer and header of the document being pulled in
but, leave the footer and header on the 1st page?
Here is what I am using for inserting:

If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then

Dim myDoc As Document
Dim docrange As Range

Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "W:WC No Treatment Letter.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
 
M

macropod

Hi Bryan,

You could use something along the lines of:

Dim myDoc As Document
Dim i As Integer
If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then
Set myDoc = ActiveDocument
With myDoc
.Unprotect
With .Range
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakNextPage
With .Sections.Last
For i = 1 To 3
With .Headers.Item(i)
.LinkToPrevious = False
.Range.Delete
End With
With .Footers.Item(i)
.LinkToPrevious = False
.Range.Delete
End With
Next i
.InsertFile "W:WC No Treatment Letter.doc"
End With
End With
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
 
B

bryan

I will try this. Thank you.
Will this allow for the document being inserted to be columned?
My template is normal outline and the doc to be inserted has 2 column format?
I had tried this before of inserting a document that had columns and it
turned into 3 pages as it inserted each column as a seperate page.
In that instance I had used docrange.InsertBreak wdPageBreak

Thanks,
Bryan

macropod said:
Hi Bryan,

You could use something along the lines of:

Dim myDoc As Document
Dim i As Integer
If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then
Set myDoc = ActiveDocument
With myDoc
.Unprotect
With .Range
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakNextPage
With .Sections.Last
For i = 1 To 3
With .Headers.Item(i)
.LinkToPrevious = False
.Range.Delete
End With
With .Footers.Item(i)
.LinkToPrevious = False
.Range.Delete
End With
Next i
.InsertFile "W:WC No Treatment Letter.doc"
End With
End With
.Protect wdAllowOnlyFormFields, NoReset
End With
End If

--
Cheers
macropod
[MVP - Microsoft Word]


bryan said:
Programmically I have used insert section break to insert a document.
First page of template has footer/header
What I would like to do for a project is to insert a document that
has 2 colums with no footer/header.
How can I turn off the footer and header of the document being pulled in
but, leave the footer and header on the 1st page?
Here is what I am using for inserting:

If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then

Dim myDoc As Document
Dim docrange As Range

Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "W:WC No Treatment Letter.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
 
M

macropod

Hi Bryan,

The No, of columns is immaterial, except that the new Section will necessarily start off with the same number of columns as the
Section into which it it inserted (jn this case the last Section in your document). If you want to change the column count for the
new Section, you could add the line:
..Range.PageSetup.TextColumns.SetCount (#)
where # is the No. of columns, to the With .Sections.Last ... End With block.

--
Cheers
macropod
[MVP - Microsoft Word]


bryan said:
I will try this. Thank you.
Will this allow for the document being inserted to be columned?
My template is normal outline and the doc to be inserted has 2 column format?
I had tried this before of inserting a document that had columns and it
turned into 3 pages as it inserted each column as a seperate page.
In that instance I had used docrange.InsertBreak wdPageBreak

Thanks,
Bryan

macropod said:
Hi Bryan,

You could use something along the lines of:

Dim myDoc As Document
Dim i As Integer
If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then
Set myDoc = ActiveDocument
With myDoc
.Unprotect
With .Range
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakNextPage
With .Sections.Last
For i = 1 To 3
With .Headers.Item(i)
.LinkToPrevious = False
.Range.Delete
End With
With .Footers.Item(i)
.LinkToPrevious = False
.Range.Delete
End With
Next i
.InsertFile "W:WC No Treatment Letter.doc"
End With
End With
.Protect wdAllowOnlyFormFields, NoReset
End With
End If

--
Cheers
macropod
[MVP - Microsoft Word]


bryan said:
Programmically I have used insert section break to insert a document.
First page of template has footer/header
What I would like to do for a project is to insert a document that
has 2 colums with no footer/header.
How can I turn off the footer and header of the document being pulled in
but, leave the footer and header on the 1st page?
Here is what I am using for inserting:

If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then

Dim myDoc As Document
Dim docrange As Range

Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "W:WC No Treatment Letter.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
 
B

bryan

Not working.
It is inserting the file (I had to add .Range to the insert) but, I have the
header and the footer on the second page. Header and footer are on page 1
which needs to stay but I do not want it on page 2.
Here is my code:
If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then

Dim myDoc As Document
Dim i As Integer

Set myDoc = ActiveDocument
With myDoc
.Unprotect
With .Range
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakNextPage
With .Sections.Last
.Range.PageSetup.TextColumns.SetCount (2)
For i = 1 To 3
With .Headers.Item(i)
.LinkToPrevious = False
.Range.Delete
End With
With .Footers.Item(i)
.LinkToPrevious = False
.Range.Delete
End With
Next i
.Range.InsertFile "U:\Claims Templates\4968\State Fraud Warnings.doc"
End With
End With
.Protect wdAllowOnlyFormFields, NoReset
End With


Thanks in advance,
Bryan
 
B

bryan

I have made this work.
I created a 2 colunm table for my document info which is added.
Here is the code I am using then to add the doc, using insert pagebreak
rather than section break.

Dim myDoc As Document
Dim docrange As Range

Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdPageBreak

Set docrange = .Range
docrange.Collapse wdCollapseEnd

docrange.InsertFile "U:\State Fraud Warnings2.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With

Thanks,
Bryan

macropod said:
Hi Bryan,

The No, of columns is immaterial, except that the new Section will necessarily start off with the same number of columns as the
Section into which it it inserted (jn this case the last Section in your document). If you want to change the column count for the
new Section, you could add the line:
..Range.PageSetup.TextColumns.SetCount (#)
where # is the No. of columns, to the With .Sections.Last ... End With block.

--
Cheers
macropod
[MVP - Microsoft Word]


bryan said:
I will try this. Thank you.
Will this allow for the document being inserted to be columned?
My template is normal outline and the doc to be inserted has 2 column format?
I had tried this before of inserting a document that had columns and it
turned into 3 pages as it inserted each column as a seperate page.
In that instance I had used docrange.InsertBreak wdPageBreak

Thanks,
Bryan

macropod said:
Hi Bryan,

You could use something along the lines of:

Dim myDoc As Document
Dim i As Integer
If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then
Set myDoc = ActiveDocument
With myDoc
.Unprotect
With .Range
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakNextPage
With .Sections.Last
For i = 1 To 3
With .Headers.Item(i)
.LinkToPrevious = False
.Range.Delete
End With
With .Footers.Item(i)
.LinkToPrevious = False
.Range.Delete
End With
Next i
.InsertFile "W:WC No Treatment Letter.doc"
End With
End With
.Protect wdAllowOnlyFormFields, NoReset
End With
End If

--
Cheers
macropod
[MVP - Microsoft Word]


Programmically I have used insert section break to insert a document.
First page of template has footer/header
What I would like to do for a project is to insert a document that
has 2 colums with no footer/header.
How can I turn off the footer and header of the document being pulled in
but, leave the footer and header on the 1st page?
Here is what I am using for inserting:

If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then

Dim myDoc As Document
Dim docrange As Range

Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "W:WC No Treatment Letter.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
 

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