A family of Microsoft word processing software products for creating web, email, and print documents.
Rainier,
Word never ceases to perplex. I'm not smart enough to say definitively that it is a bug, but it seems that way.
Regardless, if you put the CCs in a Quote field the error no longer occurs.
However, your code doesn't seem to return the desired result (not sure why you care). So changing it as follows does:
Private Sub Document_ContentControlBeforeDelete(ByVal OldContentControl As ContentControl, ByVal InUndoRedo As Boolean)
Dim isInFieldResult As Boolean
Dim oFld As Field
MsgBox OldContentControl.Range.Information(wdInFieldResult) & " - which doesn't seem to be a true statement."
For Each oFld In ActiveDocument.Fields
If OldContentControl.Range.InRange(oFld.Result) Then
isInFieldResult = True
MsgBox isInFieldResult & " - which seem more accurate."
Exit For
End If
Next oFld
isInFieldResult = OldContentControl.Range.Information(wdInFieldResult)
lbl_Exit:
Exit Sub
End Sub
An interesting side note. Look what happens when the CCs are mapped and the node values changed (to the four possible values) then updating fields:
Private Sub Document_ContentControlBeforeDelete(ByVal OldContentControl As ContentControl, ByVal InUndoRedo As Boolean)
Dim isInFieldResult As Boolean
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
If OldContentControl.Range.InRange(oFld.Result) Then
isInFieldResult = True
MsgBox isInFieldResult
Exit For
End If
Next oFld
lbl_Exit:
Exit Sub
End Sub
Sub ScratchMacro1()
'A basic Word macro coded by Greg Maxey
Dim oCC1 As ContentControl, oCC As ContentControl
Set oCC = ActiveDocument.ContentControls(1)
oCC.XMLMapping.CustomXMLPart.DocumentElement.ChildNodes(1).Text = "Rainier Lugue"
oCC.XMLMapping.CustomXMLPart.DocumentElement.ChildNodes(2).Text = "MySubject"
ActiveDocument.Fields.Update
lbl_Exit:
Exit Sub
End Sub
Sub ScratchMacro2()
'A basic Word macro coded by Greg Maxey
Dim oCC1 As ContentControl, oCC As ContentControl
Set oCC = ActiveDocument.ContentControls(1)
oCC.XMLMapping.CustomXMLPart.DocumentElement.ChildNodes(1).Text = "Rainier LugueX"
oCC.XMLMapping.CustomXMLPart.DocumentElement.ChildNodes(2).Text = "MySubject"
ActiveDocument.Fields.Update
lbl_Exit:
Exit Sub
End Sub
Sub ScratchMacro3()
'A basic Word macro coded by Greg Maxey
Dim oCC1 As ContentControl, oCC As ContentControl
Set oCC = ActiveDocument.ContentControls(1)
oCC.XMLMapping.CustomXMLPart.DocumentElement.ChildNodes(1).Text = "Rainier Lugue"
oCC.XMLMapping.CustomXMLPart.DocumentElement.ChildNodes(2).Text = "MySubjectX"
ActiveDocument.Fields.Update
lbl_Exit:
Exit Sub
End Sub
Sub ScratchMacro4()
'A basic Word macro coded by Greg Maxey
Dim oCC1 As ContentControl, oCC As ContentControl
Set oCC = ActiveDocument.ContentControls(1)
oCC.XMLMapping.CustomXMLPart.DocumentElement.ChildNodes(1).Text = "Rainier Lugue"
oCC.XMLMapping.CustomXMLPart.DocumentElement.ChildNodes(2).Text = "MySubjectX"
ActiveDocument.Fields.Update
lbl_Exit:
Exit Sub
End Sub