PDA

View Full Version : Creating a checklist in MO that only exports values selected to a MS Word doc



page
10-20-2016, 08:03 AM
Okay guys.


I have been at this for 2 days now & I really need help I am new to VBA and learning fast.


I have created a huge table in MS word that will function as a checklist. I want users to be able to check off what they want in the table and have it exported into another MS word document.

So for example in the box below Task 3, 5, 6, should be the only exports.. I would like another workbook to pop up after I run my code and it should only show me the rows checked.

WBS Summary


Task Description

Summary of Task

Checkbox



Task 1

super awesome task 1

[]



Task 2

super awesome task 2

[]



Task 3

super awesome task 3

[X]



Task 4

super awesome task 4

[]



Task 5

super awesome task 5

[X]



Task 6

super awesome task 6

[X]














.... End Result Should look like the table below in another workbook





Task Description

Summary of Task

Checkbox











Task 3

super awesome task 3

[X]











Task 5

super awesome task 5

[X]



Task 6

super awesome task 6

[X]













To give you guys some scope. This is going to be a huge WBS table for several groups who need to define what they are going to work on in a SOW. Ideally they should be able to go in select what they will do for a new project and have it exported into another doc.

Thanks Guys!
VS 2010 MS word

gmaxey
10-20-2016, 10:34 AM
I accept that you may be new to VBA but you haven't posted any code it indicate that you have learned anything yet!

Personally I would go about this differently. Create template file with your master table, create a new document based off the template then delete any row from the new document table that the user doesn't check:


Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oTbl As Table
Dim lngIndex As Long
Set oTbl = ActiveDocument.Tables(1)
For lngIndex = oTbl.Rows.Count To 2 Step -1
If oTbl.Cell(lngIndex, 3).Range.ContentControls(1).Checked = False Then
oTbl.Rows(lngIndex).Delete
Else
oTbl.Cell(lngIndex, 3).Range.ContentControls(1).Checked = False
End If
Next lngIndex
lbl_Exit:
Exit Sub
End Sub



Code assumes that your checkboxes are Content Control checkboxes.