B
bryan
I have tried this code and it works well if I select one checkbox. If I
select more than 1, it is not working correctly.
My template is a letterhead (top and bottom) as are my documents.
When I check box one, it adds temp2.doc correctly.
When I check box 2, it adds a blank letterhead after my template page, then
adds
temp3.doc as a continuation of temp2.doc rather than starting a new page.
I have in chk2 named myDoc1 and docrange1 but, that did not help
Here is the code for each check box:
Sub chk1()
'
' chk1 Macro
' Macro created 4/10/2008 by bjsorens
'
If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then
Dim myDoc As Document
Dim docrange As Range
Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = Selection.Bookmarks("\Page").Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "u:\temp2.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
End Sub
Sub chk2()
'
' chk1 Macro
' Macro created 4/10/2008 by bjsorens
'
If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then
Dim myDoc As Document
Dim docrange As Range
Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = Selection.Bookmarks("\Page").Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "u:\temp3.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
End Sub
Would appreciate any help so that by checking more than 1 box, the next file
(document) added would append after the last.
Thanks,
Bryan
select more than 1, it is not working correctly.
My template is a letterhead (top and bottom) as are my documents.
When I check box one, it adds temp2.doc correctly.
When I check box 2, it adds a blank letterhead after my template page, then
adds
temp3.doc as a continuation of temp2.doc rather than starting a new page.
I have in chk2 named myDoc1 and docrange1 but, that did not help
Here is the code for each check box:
Sub chk1()
'
' chk1 Macro
' Macro created 4/10/2008 by bjsorens
'
If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then
Dim myDoc As Document
Dim docrange As Range
Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = Selection.Bookmarks("\Page").Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "u:\temp2.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
End Sub
Sub chk2()
'
' chk1 Macro
' Macro created 4/10/2008 by bjsorens
'
If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then
Dim myDoc As Document
Dim docrange As Range
Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = Selection.Bookmarks("\Page").Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "u:\temp3.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
End Sub
Would appreciate any help so that by checking more than 1 box, the next file
(document) added would append after the last.
Thanks,
Bryan