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
>