G
Greg Maxey
To see this issue create a single row two column table and insert text
formfield in the first cell and and a REF to that formfield in the second
cell. Protect the document and add some text to the formfield.
Run this code:
Sub DumbfoundedI()
Dim oTbl As Table
Set oTbl = ActiveDocument.Tables(1)
MsgBox oTbl.Range.Fields.Count
MsgBox ActiveDocument.Fields.Count
oTbl.Range.Fields.Update
The message box proves that there are two fields in the table and in the
activedocument yet the REF field doesn't update. Does anyone know why?
However, if I run either of the following procedures the REF field does
update:
Sub DumbfoundedII()
ActiveDocument.Fields.Update
End Sub
or
Sub DumbfoundedII()
Dim oTbl As Table
Dim oFld As Field
Set oTbl = ActiveDocument.Tables(1)
For Each oFld In oTbl.Range.Fields
oFld.Update
Next oFld
End Sub
or:
Sub DumbfoundedIV()
Dim oTbl As Table
Dim oRng As Range
Set oTbl = ActiveDocument.Tables(1)
Set oRng = oTbl.Range
oRng.Start = oRng.Start + 1
oRng.End = oRng.End + 1
oRng.Fields.Update
End Sub
formfield in the first cell and and a REF to that formfield in the second
cell. Protect the document and add some text to the formfield.
Run this code:
Sub DumbfoundedI()
Dim oTbl As Table
Set oTbl = ActiveDocument.Tables(1)
MsgBox oTbl.Range.Fields.Count
MsgBox ActiveDocument.Fields.Count
oTbl.Range.Fields.Update
The message box proves that there are two fields in the table and in the
activedocument yet the REF field doesn't update. Does anyone know why?
However, if I run either of the following procedures the REF field does
update:
Sub DumbfoundedII()
ActiveDocument.Fields.Update
End Sub
or
Sub DumbfoundedII()
Dim oTbl As Table
Dim oFld As Field
Set oTbl = ActiveDocument.Tables(1)
For Each oFld In oTbl.Range.Fields
oFld.Update
Next oFld
End Sub
or:
Sub DumbfoundedIV()
Dim oTbl As Table
Dim oRng As Range
Set oTbl = ActiveDocument.Tables(1)
Set oRng = oTbl.Range
oRng.Start = oRng.Start + 1
oRng.End = oRng.End + 1
oRng.Fields.Update
End Sub