Re: next page - section break / insert file
- From: bryan <bryan@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 10 Apr 2008 07:41:01 -0700
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 towards the bottom 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
thanks,
Bryan
"bryan" wrote:
Thanks,.
Bryan
"Doug Robbins - Word MVP" wrote:
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 "Drive:\Path\Filename"
.Protect wdAllowOnlyFormFields, NoReset
End With
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"bryan" <bryan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E92DE822-E10F-4CFE-80A8-116FA381FE7D@xxxxxxxxxxxxxxxx
A 2 prong question:
I have a protected template which has 4 different check boxes. If a check
box is checked, I need to insert a section break/next page AFTER the page.
Once I have inserted the break, I then need to insert a file (document)
from
our network drive.
This example, I could insert 4 different files to my template.
Not sure how to code appropriately to add the section break or to insert
file.
Any help would be appreciated.
Thanks,
Bryan
- Follow-Ups:
- Re: next page - section break / insert file
- From: Doug Robbins - Word MVP
- Re: next page - section break / insert file
- References:
- next page - section break / insert file
- From: bryan
- Re: next page - section break / insert file
- From: Doug Robbins - Word MVP
- Re: next page - section break / insert file
- From: bryan
- next page - section break / insert file
- Prev by Date: Re: need code to get entire paragraph containing selected text
- Next by Date: Re: Date Control
- Previous by thread: Re: next page - section break / insert file
- Next by thread: Re: next page - section break / insert file
- Index(es):
Relevant Pages
|