Microsoft Office Tutorials and References
In Depth Information
Forms: Deleting a Table Row
' * * * * *¶
Sub ChangeCalculationCode(ffld As Word.FormField, _¶
nr As Long, aFieldNames() As String)¶
'Variable declaration¶
Dim calculationCode As String¶
Dim counter As Long¶
Dim ffldName As String¶
calculationCode = ffld.TextInput.Default¶
'cycle through the base field names that have been¶
'incremented. If found, add the underscore¶
'increment value to the field name in the calculation¶
For counter = 0 To UBound(aFieldNames) - 1¶
If InStr(calculationCode, aFieldNames(counter)) <> 0 Then¶
ffldName = aFieldNames(counter)¶
calculationCode = Left(calculationCode, _¶
(InStr(calculationCode, ffldName) + Len(ffldName) - 1)) _¶
& "_" & CStr(nr) & Mid(calculationCode, _¶
(InStr(calculationCode, ffldName) + Len(ffldName)))¶
End If¶
ffld.TextInput.Default = calculationCode¶
'Select it so that executing the dialog box¶
'updates the changed calculation formula¶
End Sub¶
Set the constant values, as follows:
StartRowIndex The number of rows at the top of the table to
"protect" from deletion by the macro.
EndRowsIndex The number of rows at the end of the table to
protect from deletion.
If the form is protected with a password, supply it
here. The macro must temporarily unprotect the
form in order to delete the row. If no password has
been assigned, use a zero-length string ("").
The macro runs from a toolbar that displays when a document is created using
the template.
Search JabSto ::

Custom Search