Re: Macro generates runtime error

No wonder you are getting error messages. You are adding to tables. Your
code is not set to change any values of form fields. You can't do this while
the document is protected.

What you are talking about is what Word calls an "online form." For more
about online forms, follow the links at or especially Dian
Chapman's series of articles. I strongly recommend that you work through all
of Dian Chapman's articles. They give examples of manipulating online forms
with code.

Hope this helps,

Charles Kenyon

Word New User FAQ & Web Directory:

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)

See also the MVP FAQ: which is awesome!

My criminal defense site:
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
"QDE" <QDE@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
Here's the error message: "Run-time error '6124': You are not allowed to
edit this region because document protection is in effect." The document
protected only for forms and the fields are all form fields that allow
entry. Input is accepted in all fields except those involved in the
which still runs without errors in all earlier versions of Word.

Here's the macro code:

Sub TableFormula()
' Calculate and display totals for Table 5.
Dim cLabor1Cell As Cell
Dim cLabor2Cell As Cell
Dim cBurden1Cell As Cell
Dim cBurden2Cell As Cell
Dim cMaterial1Cell As Cell
Dim cMaterial2Cell As Cell
Dim cTotal1Cell As Cell
Dim cTotal2Cell As Cell
Dim cCell1Total As Currency
Dim cCell2Total As Currency
' Set variables equal to specified cells.
Set cLabor1Cell = ActiveDocument.Tables(5).Cell(Row:=5, Column:=2)
Set cLabor2Cell = ActiveDocument.Tables(5).Cell(Row:=5, Column:=4)
Set cBurden1Cell = ActiveDocument.Tables(5).Cell(Row:=6, Column:=2)
Set cBurden2Cell = ActiveDocument.Tables(5).Cell(Row:=6, Column:=4)
Set cMaterial1Cell = ActiveDocument.Tables(5).Cell(Row:=7, Column:=2)
Set cMaterial2Cell = ActiveDocument.Tables(5).Cell(Row:=7, Column:=4)
Set cTotal1Cell = ActiveDocument.Tables(5).Cell(Row:=8, Column:=2)
Set cTotal2Cell = ActiveDocument.Tables(5).Cell(Row:=8, Column:=4)
' Calculate totals
cCell1Total = Val(cLabor1Cell.Range.Text) + Val(cBurden1Cell.Range.Text)
+ Val(cMaterial1Cell.Range.Text)
cCell2Total = Val(cLabor2Cell.Range.Text) + Val(cBurden2Cell.Range.Text)
+ Val(cMaterial2Cell.Range.Text)
' Insert results of calculations into cells C8 and E8 of Table 5.
If cCell1Total > 0 Then
cTotal1Cell.Range.Text = Format(cCell1Total, "######.00")
cTotal1Cell.Range.Text = ""
End If
If cCell2Total > 0 Then
cTotal2Cell.Range.Text = Format(cCell2Total, "######.00")
cTotal2Cell.Range.Text = ""
End If
End Sub

"Jay Freedman" wrote:

Insufficient information. Please post the code of the macro, and the
exact wording of the error message. I can't promise that a diagnosis
will be possible with that information, but it's impossible without

In the meantime, check that every field named in the macro actually
exists with exactly the same name in the form.

Jay Freedman
Microsoft Word MVP FAQ:
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 29 Apr 2006 09:44:01 -0700, QDE
<QDE@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

For ages I have been using a protected form that I created in Word 2000
uses a simple macro to add numbers entered in form fields, update a
and display the total in a form field. After the upgrade to Word 2003
field involved in the macro causes a VB runtime error. I've changed to
security and the macro still won't run on computers that have been
to 2003. Any suggestions?