To make the macro work with the least change, use Edit > Replace (in
the VBA editor, not in the main Word document) to replace all
occurrences of
.Text
with
.FormFields(1).Result
This works in both Word 2003 and Word 2000.
In fact, when I tried your original macro in Word 2000, it failed even
earlier than the same macro in Word 2003. In Word 2000 the macro
refused to read the values of the fields in rows 5, 6, and 7; in Word
2003 it would read those values, but then refused to set the totals in
row 8.
The problem is that you're trying to read and write the contents of
the *cells*, not the *form fields in the cells*. In a protected
document, only the contents of the form fields is accessible to VBA,
just as in the user interface.
An all-around better method would be to go into the Properties dialog
of each form field and set its "bookmark name" to an appropriate name.
For example, name them Labor1, Labor 2, Burden1, etc. Then, instead of
declaring and manipulating cells, do all the work directly with the
form fields. The macro would look something like this:
Sub TableFormula()
' Calculate and display totals for Table 5.
Dim Labor1 As FormField
Dim Labor2 As FormField
Dim Burden1 As FormField
Dim Burden2 As FormField
Dim Material1 As FormField
Dim Material2 As FormField
Dim Total1 As FormField
Dim Total2 As FormField
Dim cCell1Total As Currency
Dim cCell2Total As Currency
' Set variables equal to specified cells.
Set Labor1 = ActiveDocument.FormFields("Labor1")
Set Labor2 = ActiveDocument.FormFields("Labor2")
Set Burden1 = ActiveDocument.FormFields("Burden1")
Set Burden2 = ActiveDocument.FormFields("Burden2")
Set Material1 = ActiveDocument.FormFields("Material1")
Set Material2 = ActiveDocument.FormFields("Material2")
Set Total1 = ActiveDocument.FormFields("Total1")
Set Total2 = ActiveDocument.FormFields("Total2")
' Calculate totals
cCell1Total = Val(Labor1.Result) + Val(Burden1.Result) +
Val(Material1.Result)
cCell2Total = Val(Labor2.Result) + Val(Burden2.Result) +
Val(Material2.Result)
' Insert results of calculations into cells C8 and E8 of Table 5.
If cCell1Total > 0 Then
Total1.Result = Format(cCell1Total, "######.00")
Else
Total1.Result = ""
End If
If cCell2Total > 0 Then
Total2.Result = Format(cCell2Total, "######.00")
Else
Total2.Result = ""
End If
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.