That would only delete the last document added, but you could use code to
count the number of check boxes that had been checked and then run code to
delete the last section that number of times.
Instead of re-inventing the wheel however, you may want to consider the
Boiler Plate Features of DataPrompter available from
http://www.wordsite.com/
--
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"
news:A0C5AC56-4A51-4D3E-89CB-5CC9B6B32481@microsoft.com...
> On the protected form they could add multiple documents so in order to
> remove
> one in the middle it would probably be best to have a "Refresh" macro
> button
> on the form to remove all added documents and start over.
> How would I remove "All" ? Would it be just removing the .Last ?
>
> Also, Where is a good source for learning Word programming?
>
> Thanks again,
> Bryan
>
> "Doug Robbins - Word MVP" wrote:
>
>> Dim rnge As Range
>> Set rnge = ActiveDocument.Sections.Last.Range
>> rnge.start = rnge.start - 1
>> rnge.Delete
>>
>>
>> --
>> 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"
>> news:B6ADD70C-241B-4771-87E3-BF23207DE508@microsoft.com...
>> > How would you delete a document that was added?
>> >
>> > Bryan
>> >
>> > "Doug Robbins - Word MVP" wrote:
>> >
>> >> It should work for any number of checkboxes, except that you are doing
>> >> to
>> >> need to supply the name of the file to insert each time.
>> >>
>> >> An immediate undo of the result of clicking a checkbox would be
>> >> possible
>> >> by
>> >> deleting the last Section of the document. It will be a tad more
>> >> complicated if another checkbox had been checked before the undo of
>> >> the
>> >> action of checking a previous one is required.
>> >>
>> >> --
>> >> 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"
>> >> news:7ACB03AF-AF71-426A-A38F-7090DD37DAA1@microsoft.com...
>> >> > Thanks Doug,
>> >> > Will this work no matter how many check boxes I have?
>> >> > If have 5 different check boxes with the potential of including 5
>> >> > different
>> >> > documents they will append at the bottom?
>> >> > In other words:
>> >> > For each check box I use the same code as described here for check2?
>> >> >
>> >> > Another question on this topic:
>> >> > Let's say they inadvertantly check box 1 and it adds the document,
>> >> > they
>> >> > uncheck box 1, is there then a way to delete?
>> >> >
>> >> > Thanks,
>> >> > Bryan
>> >> >
>> >> >
>> >> > "Doug Robbins - Word MVP" wrote:
>> >> >
>> >> >> If you always want the documents added at the end of the document
>> >> >> in a
>> >> >> new
>> >> >> section, use:
>> >> >>
>> >> >> 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 "u:\temp3.doc"
>> >> >> .Protect wdAllowOnlyFormFields, NoReset
>> >> >> End With
>> >> >> End If
>> >> >>
>> >> >>
>> >> >> --
>> >> >> 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"
>> >> >> news:EDAA8F25-032B-4098-B974-D9864C8E0B1D@microsoft.com...
>> >> >> >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
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>