This was previously discussed as subject "RE: if chkbox is ticked then
un-strikethrough textbox text" - where I used an active-x control as the
checkbox, but I found out that I need to use a protected form. I want to
convert Jean-Guy Marcil's code (thank you Jean!) to something I can use with
a protected checkbox.

So far I have...

Sub Click() 'I call this in the checkbox properties - run macro on
entry/exit
ToggleStrikeThru Selection.Range
End Sub

I get a Runtime Error 5941 with the next part (The requested member of the
collection does not exist)

Sub ToggleStrikeThru(rngStrike As Range)

With rngStrike.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
End Sub

RE: protected form checkbox macro by JeanGuyMarcil

JeanGuyMarcil
Tue May 13 09:15:11 PDT 2008

"DDawson" wrote:

> This was previously discussed as subject "RE: if chkbox is ticked then
> un-strikethrough textbox text" - where I used an active-x control as the
> checkbox, but I found out that I need to use a protected form. I want to
> convert Jean-Guy Marcil's code (thank you Jean!) to something I can use with
> a protected checkbox.
>
> So far I have...

Two things...
1) The code I previously posted was working with ActiveX controls, which are
different from form fields ("InlineShapes(1).OLEFormat" vs
"FormFields(1).CheckBoxes")
2) To work with text in a protected document, you have to first unprotect
it...

Try this:


Sub Click()

ToggleStrikeThru Selection.Range

End Sub


Sub ToggleStrikeThru(rngStrike As Range)

ActiveDocument.Unprotect

With rngStrike.Rows(1)
.Cells(2).Range.Font.DoubleStrikeThrough = Not _
.Cells(1).Range.FormFields(1).CheckBox.Value
.Cells(3).Range.Font.DoubleStrikeThrough = Not _
.Cells(1).Range.FormFields(1).CheckBox.Value
End With

ActiveDocument.Protect wdAllowOnlyFormFields, True

End Sub

Re: protected form checkbox macro by dd

dd
Tue May 13 11:19:47 PDT 2008

Hi Jean

I've tried this at home, using Word 2000 and I find when I click the
checkbox nothing happens, but then when I click another cell, after clicking
the textbox, it works.

I've added screen updating to the beginning and end, but no difference.
I've tried to add .Cells(2).Select, to the end of the With
rngStrike.Rows(1), but this doesn't work either.

Is there anything else you can do to make it update on clicking?

Dylan

"Jean-Guy Marcil" <JeanGuyMarcil@discussions.microsoft.com> wrote in message
news:EBFBC1E5-37FC-4EFB-B8BF-3428405533A0@microsoft.com...
> "DDawson" wrote:
>
>> This was previously discussed as subject "RE: if chkbox is ticked then
>> un-strikethrough textbox text" - where I used an active-x control as the
>> checkbox, but I found out that I need to use a protected form. I want to
>> convert Jean-Guy Marcil's code (thank you Jean!) to something I can use
>> with
>> a protected checkbox.
>>
>> So far I have...
>
> Two things...
> 1) The code I previously posted was working with ActiveX controls, which
> are
> different from form fields ("InlineShapes(1).OLEFormat" vs
> "FormFields(1).CheckBoxes")
> 2) To work with text in a protected document, you have to first unprotect
> it...
>
> Try this:
>
>
> Sub Click()
>
> ToggleStrikeThru Selection.Range
>
> End Sub
>
>
> Sub ToggleStrikeThru(rngStrike As Range)
>
> ActiveDocument.Unprotect
>
> With rngStrike.Rows(1)
> .Cells(2).Range.Font.DoubleStrikeThrough = Not _
> .Cells(1).Range.FormFields(1).CheckBox.Value
> .Cells(3).Range.Font.DoubleStrikeThrough = Not _
> .Cells(1).Range.FormFields(1).CheckBox.Value
> End With
>
> ActiveDocument.Protect wdAllowOnlyFormFields, True
>
> End Sub



Re: protected form checkbox macro by JeanGuyMarcil

JeanGuyMarcil
Tue May 13 13:28:00 PDT 2008

"dd" wrote:

> Hi Jean
>
> I've tried this at home, using Word 2000 and I find when I click the
> checkbox nothing happens, but then when I click another cell, after clicking
> the textbox, it works.
>
> I've added screen updating to the beginning and end, but no difference.
> I've tried to add .Cells(2).Select, to the end of the With
> rngStrike.Rows(1), but this doesn't work either.
>
> Is there anything else you can do to make it update on clicking?

No!
Remember, the trigger is an "OnExit" event, not a "Click" event. You have to
leave the checkbox for the code to be triggered... either tab out, or click
elsewhere...

Re: protected form checkbox macro by dd

dd
Tue May 13 14:39:06 PDT 2008

Jean-Guy,

This is excellent and it does exactly what I want, but can you tell me how
to reverse it so that when the checkbox is checked - the text is
struckthrough.

Hope its not too much trouble, I really appreciate it.

Dylan

"Jean-Guy Marcil" <JeanGuyMarcil@discussions.microsoft.com> wrote in message
news:A1CECDDD-5234-47A2-A089-BED866F0B472@microsoft.com...
> "dd" wrote:
>
>> Hi Jean
>>
>> I've tried this at home, using Word 2000 and I find when I click the
>> checkbox nothing happens, but then when I click another cell, after
>> clicking
>> the textbox, it works.
>>
>> I've added screen updating to the beginning and end, but no difference.
>> I've tried to add .Cells(2).Select, to the end of the With
>> rngStrike.Rows(1), but this doesn't work either.
>>
>> Is there anything else you can do to make it update on clicking?
>
> No!
> Remember, the trigger is an "OnExit" event, not a "Click" event. You have
> to
> leave the checkbox for the code to be triggered... either tab out, or
> click
> elsewhere...