Create Multiple Forms from Check Boxes

D

dgold82

I have about 50 forms that I would like to integrate into one word doc.
Basically, I want my employees to be able to open one file and the first page
is 50 check boxes each corresponding to a form that would be created in the
subsequent pages if checked.

A great perk would be that if the box is checked then it then becomes
highlighted so that we all know which forms were created for that file just
by looking at the first page. A super great perk would be that the check box
and text next to it would become a hyperlink to that form in the doc.

I have a feeling that macros need to be created but I don't know how to make
them so if you could point me in the right direction that would be great.

Any ideas?
Thanks!
 
J

Jean-Guy Marcil

dgold82 said:
I have about 50 forms that I would like to integrate into one word doc.
Basically, I want my employees to be able to open one file and the first page
is 50 check boxes each corresponding to a form that would be created in the
subsequent pages if checked.

A great perk would be that if the box is checked then it then becomes
highlighted so that we all know which forms were created for that file just
by looking at the first page. A super great perk would be that the check box
and text next to it would become a hyperlink to that form in the doc.

I have a feeling that macros need to be created but I don't know how to make
them so if you could point me in the right direction that would be great.

Any ideas?

If you are not really familiar with macros, I would strongly suggest you
hire somebody to do this for you.
This is not a very simple project that we can code for you in a few minutes,
like we normally do when helping out people who have already written code and
who are stuck on a line of code or two...
Someone who knows what he/she is doing could also add code so that if a user
made a mistake, he/she could uncheck a box and remove that form from the list
of forms.

Meanwhile, you may be in luck! Maybe that someone has already written
something similar and is willing to post the code...
 
D

dgold82

Thanks. I thought this might be the case. Do you know a good site that could
help me learn how to write something like this?
 
G

Graham Mayor

Although not strictly addressing the issue you have raised, the last example
at http://www.gmayor.com/word_vba_examples.htm covers the insertion of form
fields based on the content of a single field (which could just as easily be
a check box). As you will see from the code (which addresses just one such
field) the complexity of what you propose is quite daunting.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

dgold82

Thanks for the tip. While this was simple in my head it has not been simple
to do in Word (as you all are saying). What I ended up doing is putting on 50
forms in one long continuous document and building a table of contents in the
beginning with checkboxed next to each header in the table.

Since I have 50 forms I needed the checkbox next to each table of content so
that we know which ones have been filled out. It would be nice if I can
somehow have word automatically highlight the row or checkbox if it is
checked so it stands out a little more.
 
G

Graham Mayor

The following macro "EmphasiseCheckedBox" when applied to the on exit
function of the checkbox will colour that check box red if it is checked
Create a module in the form template and copy the code to it -
http://www.gmayor.com/installing_macro.htm

Private mstrFF As String
Sub EmphasiseCheckedBox()
Dim oFld As FormFields
Dim sCount As Integer
Dim bProtected As Boolean
Dim sPassword As String

sPassword = "" 'Insert the password (if any), used to protect the form
between the quotes
With GetCurrentFF 'Establish field is current
mstrFF = GetCurrentFF.name
End With

Set oFld = ActiveDocument.FormFields
sCount = oFld(mstrFF).CheckBox.Value 'Get the Checkbox field value
'Check if the document is protected and if so unprotect it

If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

With oFld(mstrFF).Range
If sCount = True Then
.Font.Color = wdColorRed
Else
.Font.Color = wdColorAutomatic
End If
End With
Quit: 'Re-protect the form and apply the password (if any).
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If
End Sub

Private Function GetCurrentFF() As Word.FormField
Dim rngFF As Word.Range
Dim fldFF As Word.FormField
Set rngFF = Selection.Range
rngFF.Expand wdParagraph
For Each fldFF In rngFF.FormFields
Set GetCurrentFF = fldFF
Exit For
Next
End Function

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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