M
mattchorno
Hi. I am using Word 2003 and have a document that has 3 sections. I
have the first section protected leaving the other 2 unprotected. In
one of the unprotected sections I have a table. I have a macro that
uses a loop to populates that table. Code is:
For i = 1 To UBound(CAPSID)
If i <> 1 Then '--if not on first cell in table
ActiveDocument.Tables(2).Rows.Add '--add a row to the table
End If
With ActiveDocument.Tables(2).Cell(Row:=i, Column:=1).Range
.InsertAfter Text:=CAPSID(i) '--CAPSID is an array that stores
text values
End With
Next i
However when I run the macro I get the runtime error 6124: "You are
not allowed to edit this region because document protection is in
effect". The first part of the code works (inserting a row into the
table), but it will not insert text into it. Why am I getting this
error if the table is in an unprotected section of the document? I am
able to type into the table manually, but running the code throws an
error. If I turn off all protection it works fine. I know the work
around, but I'd rather not turn off and on protection during the
macro. I don't see why it shouldn't work if the table is not in a
protected part of the document. I wrote this program a long time ago
and I don't remember it not working before. I think it may have
started not working after moving to Word 2003, but am not sure. Any
clues?
have the first section protected leaving the other 2 unprotected. In
one of the unprotected sections I have a table. I have a macro that
uses a loop to populates that table. Code is:
For i = 1 To UBound(CAPSID)
If i <> 1 Then '--if not on first cell in table
ActiveDocument.Tables(2).Rows.Add '--add a row to the table
End If
With ActiveDocument.Tables(2).Cell(Row:=i, Column:=1).Range
.InsertAfter Text:=CAPSID(i) '--CAPSID is an array that stores
text values
End With
Next i
However when I run the macro I get the runtime error 6124: "You are
not allowed to edit this region because document protection is in
effect". The first part of the code works (inserting a row into the
table), but it will not insert text into it. Why am I getting this
error if the table is in an unprotected section of the document? I am
able to type into the table manually, but running the code throws an
error. If I turn off all protection it works fine. I know the work
around, but I'd rather not turn off and on protection during the
macro. I don't see why it shouldn't work if the table is not in a
protected part of the document. I wrote this program a long time ago
and I don't remember it not working before. I think it may have
started not working after moving to Word 2003, but am not sure. Any
clues?