S
SGagnon
Hello:
I have a .dot with a couple of tables in it.
There are ActiveX buttons in the form to add/remove rows from the table.
The Add button resides inside a cell in the last row in the table. The
Remove button is in the header row. Each row in between contains an ActiveX
checkbox to mark it for removal.
If, while working on the .dot, I protect the form, I can then click on the
Add/Remove buttons repeatedly and it all seems to work. The logic for
adding/removing toggles the protection on the form before & after making the
addition/removal.
If I protect the .dot and save it, and then use it to create a .doc: The
ActiveX button logic works one time only. The second click of the button
yields nothing.
I thought that perhaps it was a password problem, but the same thing happens
whether there is a password or not.
Below is the code for the Add button, and the ToggleProtection method.
Can anyone see anything wrong offhand, or can you tell me how I might debug
this?
Thanks for your help.
Suzanne.
----------------
Private Sub AddDepRow()
Dim ffPartNum, ffCkChg, ffPartDesc As FormField
Dim rngCell As Range
ToggleProtection
Selection.Tables(1).Rows.Add BeforeRow:=Selection.Rows(1)
vNewRowIndex = Selection.Tables(1).Rows.Count - 1
With Selection.Tables(1).Rows(vNewRowIndex)
.Borders.OutsideLineStyle = wdLineStyleDouble
.Borders.InsideLineStyle = wdLineStyleSingle
.Borders(wdBorderTop).LineStyle = wdLineStyleSingle
End With
Set rngCell = Selection.Tables(1).Rows(vNewRowIndex).Cells(1).Range
rngCell.Text = ""
rngCell.Collapse
Set ffPartNum = ActiveDocument.FormFields.Add(rngCell,
wdFieldFormTextInput)
ffPartNum.Name = "txtDepPartNum"
Set rngCell = Selection.Tables(1).Rows(vNewRowIndex).Cells(2).Range
rngCell.Text = ""
rngCell.Collapse
Set ffCkChg = ActiveDocument.FormFields.Add(rngCell,
wdFieldFormCheckBox)
ffCkChg.Name = "ckDepChg"
Set rngCell = Selection.Tables(1).Rows(vNewRowIndex).Cells(3).Range
rngCell.Text = ""
rngCell.Collapse
Set ffPartDesc = ActiveDocument.FormFields.Add(rngCell,
wdFieldFormTextInput)
ffPartDesc.Name = "txtDepDesc"
ffPartDesc.ExitMacro = "OnDepDesc"
Set rngCell = Selection.Tables(1).Rows(vNewRowIndex).Cells(4).Range
rngCell.Text = ""
rngCell.Collapse
Dim oleCB As InlineShape
Set oleCB =
ActiveDocument.InlineShapes.AddOLEControl("Forms.CheckBox.1", rngCell)
With oleCB.OLEFormat.Object
.Caption = ""
.Width = 12.75
.Height = 14.25
End With
ToggleProtection
Selection.Tables(1).Rows(vNewRowIndex).Select
End Sub
----------------------
Sub ToggleProtection()
'
' ToggleProtection Macro
' Macro created 3/31/2004 by Suzanne
'
With ActiveDocument
If .ProtectionType = wdNoProtection Then
.Protect noreset:=True, Type:=wdAllowOnlyFormFields
Else
.Unprotect
End If
End With
End Sub
I have a .dot with a couple of tables in it.
There are ActiveX buttons in the form to add/remove rows from the table.
The Add button resides inside a cell in the last row in the table. The
Remove button is in the header row. Each row in between contains an ActiveX
checkbox to mark it for removal.
If, while working on the .dot, I protect the form, I can then click on the
Add/Remove buttons repeatedly and it all seems to work. The logic for
adding/removing toggles the protection on the form before & after making the
addition/removal.
If I protect the .dot and save it, and then use it to create a .doc: The
ActiveX button logic works one time only. The second click of the button
yields nothing.
I thought that perhaps it was a password problem, but the same thing happens
whether there is a password or not.
Below is the code for the Add button, and the ToggleProtection method.
Can anyone see anything wrong offhand, or can you tell me how I might debug
this?
Thanks for your help.
Suzanne.
----------------
Private Sub AddDepRow()
Dim ffPartNum, ffCkChg, ffPartDesc As FormField
Dim rngCell As Range
ToggleProtection
Selection.Tables(1).Rows.Add BeforeRow:=Selection.Rows(1)
vNewRowIndex = Selection.Tables(1).Rows.Count - 1
With Selection.Tables(1).Rows(vNewRowIndex)
.Borders.OutsideLineStyle = wdLineStyleDouble
.Borders.InsideLineStyle = wdLineStyleSingle
.Borders(wdBorderTop).LineStyle = wdLineStyleSingle
End With
Set rngCell = Selection.Tables(1).Rows(vNewRowIndex).Cells(1).Range
rngCell.Text = ""
rngCell.Collapse
Set ffPartNum = ActiveDocument.FormFields.Add(rngCell,
wdFieldFormTextInput)
ffPartNum.Name = "txtDepPartNum"
Set rngCell = Selection.Tables(1).Rows(vNewRowIndex).Cells(2).Range
rngCell.Text = ""
rngCell.Collapse
Set ffCkChg = ActiveDocument.FormFields.Add(rngCell,
wdFieldFormCheckBox)
ffCkChg.Name = "ckDepChg"
Set rngCell = Selection.Tables(1).Rows(vNewRowIndex).Cells(3).Range
rngCell.Text = ""
rngCell.Collapse
Set ffPartDesc = ActiveDocument.FormFields.Add(rngCell,
wdFieldFormTextInput)
ffPartDesc.Name = "txtDepDesc"
ffPartDesc.ExitMacro = "OnDepDesc"
Set rngCell = Selection.Tables(1).Rows(vNewRowIndex).Cells(4).Range
rngCell.Text = ""
rngCell.Collapse
Dim oleCB As InlineShape
Set oleCB =
ActiveDocument.InlineShapes.AddOLEControl("Forms.CheckBox.1", rngCell)
With oleCB.OLEFormat.Object
.Caption = ""
.Width = 12.75
.Height = 14.25
End With
ToggleProtection
Selection.Tables(1).Rows(vNewRowIndex).Select
End Sub
----------------------
Sub ToggleProtection()
'
' ToggleProtection Macro
' Macro created 3/31/2004 by Suzanne
'
With ActiveDocument
If .ProtectionType = wdNoProtection Then
.Protect noreset:=True, Type:=wdAllowOnlyFormFields
Else
.Unprotect
End If
End With
End Sub