Microsoft Office Tutorials and References
In Depth Information
Forms: Inserting a New Table Row
Next counter¶
doc.Protect Type:=wdAllowOnlyFormFields, noreset:=True,
password:=password¶
rng.FormFields(1).Select¶
End Sub¶
' * * * * *¶
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¶
Next¶
ffld.TextInput.Default = calculationCode¶
'Select it so that executing the dialog box¶
'updates the changed calculation formula¶
ffld.Select¶
Application.Dialogs(wdDialogFormFieldOptions).Execute¶
Selection.Range.FormFields(1).TextInput.Clear¶
End Sub¶
Wrd
The following code is included for completeness. The next example details how
it is used.
Option explicit¶
' * * * * *¶
'First row containing form fields¶
'that should not be deleted¶
Const StartRowIndex As Long = 2¶
' * * * * *¶
Sub DeleteCurrentRow()¶
'varaible declaration¶
Dim doc As Word.Document¶
Dim rng As Word.Range¶
Dim totalRows As Long¶
Set rng = Selection.Range¶
If rng.Information(wdWithInTable) Then¶
Search JabSto ::




Custom Search