B
bryan
I am posting this new looking for some help. I have posted this before but my
last post went unanswered.
I have a template with header and footer.
In the template is a checkbox to insert a file, which I want to insert
without a header and footer.
I could insert just pagebreak but, that will not allow me to update fields
in the added file only.
How can I not have the header/footer carry forward?
Here is the code I am using:
Sub chk1()
'
' chk1 Macro
' Macro created 12/2/2008 by bjsorens
'
If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then
stringfile = "W:\Claims\ImageRight\document attachments\"
docoa = "Driver Statement.doc"
Dim myDoc As Document
Dim i As Integer
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
.Range.InsertFile stringfile & docoa
End With
End With
.Protect wdAllowOnlyFormFields, NoReset
End With
Else
End If
End Sub
Thanks,
Bryan
last post went unanswered.
I have a template with header and footer.
In the template is a checkbox to insert a file, which I want to insert
without a header and footer.
I could insert just pagebreak but, that will not allow me to update fields
in the added file only.
How can I not have the header/footer carry forward?
Here is the code I am using:
Sub chk1()
'
' chk1 Macro
' Macro created 12/2/2008 by bjsorens
'
If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then
stringfile = "W:\Claims\ImageRight\document attachments\"
docoa = "Driver Statement.doc"
Dim myDoc As Document
Dim i As Integer
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
.Range.InsertFile stringfile & docoa
End With
End With
.Protect wdAllowOnlyFormFields, NoReset
End With
Else
End If
End Sub
Thanks,
Bryan