D
Dylan
I have a protected table of two rows with one row headings, the next row
contains a checkbox to allow the user to strikeout text in the adjacent cell.
The problem is that the cell containing the checkbox doesn't lose its focus
to enable the event to be initiated.
Since the document is protected and only one cell is active on this table,
whenever I select one of the other cells in the table, the focus returns to
the cell containing the checkbox.
The code I'm using, courtesy of Jean-Guy Marcil:
ToggleStrikeThru Selection.Range
ActiveDocument.Tables(1).Rows.Last.Select
End Sub
Sub ToggleStrikeThru(rngStrike As Range)
On Error Resume Next
Application.ScreenUpdating = False
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
With rngStrike.Rows(1)
.Cells(1).Range.Font.DoubleStrikeThrough = Not _
.Cells(2).Range.FormFields(1).CheckBox.Value
'.Next.Select
End With
'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
Application.ScreenUpdating = True
End Sub
contains a checkbox to allow the user to strikeout text in the adjacent cell.
The problem is that the cell containing the checkbox doesn't lose its focus
to enable the event to be initiated.
Since the document is protected and only one cell is active on this table,
whenever I select one of the other cells in the table, the focus returns to
the cell containing the checkbox.
The code I'm using, courtesy of Jean-Guy Marcil:
ToggleStrikeThru Selection.Range
ActiveDocument.Tables(1).Rows.Last.Select
End Sub
Sub ToggleStrikeThru(rngStrike As Range)
On Error Resume Next
Application.ScreenUpdating = False
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
With rngStrike.Rows(1)
.Cells(1).Range.Font.DoubleStrikeThrough = Not _
.Cells(2).Range.FormFields(1).CheckBox.Value
'.Next.Select
End With
'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
Application.ScreenUpdating = True
End Sub