Hi, I want to make a word document into a form that I can both protect and
also allow users to input data into, but I don't know if I'm going about it
the right way.

I'm using the control toolbox to create several checkboxes and adjacent
textboxes on my document. I have put some default text into the control boxes
which I want to make strikethrough format out by default. I don't know how to
do this.

Essentially, I want to allow the users to select the checkbox beside the
text to unstrike it, thus enabling the text to be shown normally. So that the
user is picking specific clauses that they want to form part of their
contract.

I don't know where to put the code. For example, if I was using a userform
the code would be part of the form. In this case, is the code part of the
thisdocument object and if so what event should I use e.g. click, change,
gotfocus?

If my textbox is called txt1 and my checkbox is chk1 can you give me some
example code on how I do this.

Kind regards
Dylan Dawson

RE: if chkbox is ticked then un-strikethrough textbox text by JeanGuyMarcil

JeanGuyMarcil
Fri May 09 09:51:01 PDT 2008

"DDawson" wrote:

> Hi, I want to make a word document into a form that I can both protect and
> also allow users to input data into, but I don't know if I'm going about it
> the right way.
>
> I'm using the control toolbox to create several checkboxes and adjacent
> textboxes on my document. I have put some default text into the control boxes
> which I want to make strikethrough format out by default. I don't know how to
> do this.
>
> Essentially, I want to allow the users to select the checkbox beside the
> text to unstrike it, thus enabling the text to be shown normally. So that the
> user is picking specific clauses that they want to form part of their
> contract.
>
> I don't know where to put the code. For example, if I was using a userform
> the code would be part of the form. In this case, is the code part of the
> thisdocument object and if so what event should I use e.g. click, change,
> gotfocus?
>
> If my textbox is called txt1 and my checkbox is chk1 can you give me some
> example code on how I do this.

You cannot format text inisde a textbox. Why are you using textboxes anyway?

It does not look like you are using a protected form. So, in this case, I
would do this:

Build a 2-column table (It can be borderless). In the first narrow colum,
place the caption-less checkboxes. Put your strikethrough text in the second
column.

Then call this macro in the Click event of each of the texboxes.

For example, for 4 checkboxes, you would end up with:


Option Explicit

Private Sub CheckBox1_Click()

ToggleStrikeThru Selection.Range

End Sub

Private Sub CheckBox2_Click()

ToggleStrikeThru Selection.Range

End Sub

Private Sub CheckBox3_Click()

ToggleStrikeThru Selection.Range

End Sub

Private Sub CheckBox4_Click()

ToggleStrikeThru Selection.Range

End Sub

Sub ToggleStrikeThru(rngStrike As Range)

With rngStrike.Rows(1)
.Cells(2).Range.Font.StrikeThrough = Not _
.Cells(1).Range.InlineShapes(1).OLEFormat.Object.Value
End With

End Sub


RE: if chkbox is ticked then un-strikethrough textbox text by DDawson

DDawson
Mon May 12 05:58:03 PDT 2008

Thanks Jean,

Your macro does exactly what I want, but I also have several drop down
lists. It seems to be a lot easier to drop down lists using protected form
fields. (Also I find the document is quite slow to open - maybe becasue there
are 44 checkboxes?).

How would I change the macro so that I can pick it from Form Field options;
run macro on entry/exit, so that it does the same thing?

I really appreciate it.

Thanks
Dylan

"Jean-Guy Marcil" wrote:

> "DDawson" wrote:
>
> > Hi, I want to make a word document into a form that I can both protect and
> > also allow users to input data into, but I don't know if I'm going about it
> > the right way.
> >
> > I'm using the control toolbox to create several checkboxes and adjacent
> > textboxes on my document. I have put some default text into the control boxes
> > which I want to make strikethrough format out by default. I don't know how to
> > do this.
> >
> > Essentially, I want to allow the users to select the checkbox beside the
> > text to unstrike it, thus enabling the text to be shown normally. So that the
> > user is picking specific clauses that they want to form part of their
> > contract.
> >
> > I don't know where to put the code. For example, if I was using a userform
> > the code would be part of the form. In this case, is the code part of the
> > thisdocument object and if so what event should I use e.g. click, change,
> > gotfocus?
> >
> > If my textbox is called txt1 and my checkbox is chk1 can you give me some
> > example code on how I do this.
>
> You cannot format text inisde a textbox. Why are you using textboxes anyway?
>
> It does not look like you are using a protected form. So, in this case, I
> would do this:
>
> Build a 2-column table (It can be borderless). In the first narrow colum,
> place the caption-less checkboxes. Put your strikethrough text in the second
> column.
>
> Then call this macro in the Click event of each of the texboxes.
>
> For example, for 4 checkboxes, you would end up with:
>
>
> Option Explicit
>
> Private Sub CheckBox1_Click()
>
> ToggleStrikeThru Selection.Range
>
> End Sub
>
> Private Sub CheckBox2_Click()
>
> ToggleStrikeThru Selection.Range
>
> End Sub
>
> Private Sub CheckBox3_Click()
>
> ToggleStrikeThru Selection.Range
>
> End Sub
>
> Private Sub CheckBox4_Click()
>
> ToggleStrikeThru Selection.Range
>
> End Sub
>
> Sub ToggleStrikeThru(rngStrike As Range)
>
> With rngStrike.Rows(1)
> .Cells(2).Range.Font.StrikeThrough = Not _
> .Cells(1).Range.InlineShapes(1).OLEFormat.Object.Value
> End With
>
> End Sub
>

RE: if chkbox is ticked then un-strikethrough textbox text by JeanGuyMarcil

JeanGuyMarcil
Tue May 13 05:28:06 PDT 2008

"DDawson" wrote:

> Thanks Jean,
>
> Your macro does exactly what I want, but I also have several drop down
> lists. It seems to be a lot easier to drop down lists using protected form
> fields. (Also I find the document is quite slow to open - maybe becasue there
> are 44 checkboxes?).
>
> How would I change the macro so that I can pick it from Form Field options;
> run macro on entry/exit, so that it does the same thing?
>

How would the macro know if strike-through needs to be applied or not?

Please describe with more accuracy what your document looks like and the
logical relationship betwen the various parts.

RE: if chkbox is ticked then un-strikethrough textbox text by Dylan

Dylan
Tue May 13 06:03:03 PDT 2008

Hi Jean

I have a three column table, the first column contains the protected
checkbox, the second contains the clause nr, and the third contains a
description of the clause.

The intention is to have all checkboxes checked and all the text clear. The
form will be issued by Project Managers (PM) to delegate authority to depute
project managers. Each clause contains an item of responsibility that may be
delegated.

When a PM decides a clause doesn't apply he can uncheck the checkbox and the
adjacent clause will then be struck-out with double strike-through
formatting. To reselect the clause, the PM can check the checkbox and the
double strike-through formatting will be removed.

I'm trying to assign a macro in the Chechbox Formfield Options dialog and
I've tried noodling with the code you sent me previously. I think I'm getting
stuch on trying to assign the Range. Here's what I currently have:

Sub StrikeThru()
'On Error Resume Next

Dim bProtected As Boolean
Dim Range As Range
Range = Selection.Rows(1).Range

'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If

'With rngStrike.Rows(1)
With Range.Rows(1)
.Cells(2).Range.Font.DoubleStrikeThrough = Not _
.Cells(1).Range.InlineShapes(1).OLEFormat.Object.Value
.Cells(3).Range.Font.DoubleStrikeThrough = Not _
.Cells(1).Range.InlineShapes(1).OLEFormat.Object.Value
End With

'Reprotect the document.
If bProtected = True Then
ActiveDocument.protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If

End Sub

Kind regards
Dylan Dawson