using checkbox to delete a section of text

S

shawn

I have a template that has 20 sections that I use daily and need to be able
to delete different sections each time. I am not sure what the best way
would be to set it up but I think that I would like to have a UserForm come
up when the document is opened that would list all of the sections with check
boxes by each. Then I could select the check boxes that go with each section
that I want to keep and then when I exit the user form all of the unchecked
items are deleted.

I am open to different suggestions if there is an easier way.

thanks alot for the help.
 
R

Russ

Shawn,
I have a template that has 20 sections that I use daily and need to be able
to delete different sections each time. I am not sure what the best way
would be to set it up but I think that I would like to have a UserForm come
up when the document is opened that would list all of the sections with check
boxes by each. Then I could select the check boxes that go with each section
that I want to keep and then when I exit the user form all of the unchecked
items are deleted.

I am open to different suggestions if there is an easier way.

I think an easier way would be to set things up to be able to use Outline
view in Word. You would have the pseudo self-labeled sections that can be
expanded and collapsed for more focused viewing and when collapsed, can be
selected and deleted or moved around.
 
R

rub

Won't something like this work:

Private Sub CommandButton1_Click()
Dim i As Integer
For i = 20 To 1
If CheckBox(i).Value = True Then
ActiveDocument.Sections(i).Range.Delete
End If
Next
End Sub

You would need to start at the end because once you delete a section
its section # changes.
 

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