G
Greg Maxey
While assisting a user in another string. I came upon the following
behaviour that appears to be a bug.
Create new document and add a line of text. Go down a few lines and add a
few content controls. Run these three macros in order:
Sub SetInitialShading()
Dim objCCs As ContentControls
Dim i As Long
ActiveDocument.Paragraphs(1).Range.Shading.BackgroundPatternColor =
wdColorLightYellow
Set objCCs = ActiveDocument.ContentControls
For i = 1 To objCCs.Count
DoEvents
objCCs(i).Range.Shading.BackgroundPatternColor = wdColorLightYellow
Next i
End Sub
Everything is shaded as expected.
Sub SetNewShading()
Dim objCCs As ContentControls
Dim i As Long
ActiveDocument.Paragraphs(1).Range.Shading.BackgroundPatternColor =
wdColorLightGreen
Set objCCs = ActiveDocument.ContentControls
For i = 1 To objCCs.Count
DoEvents
objCCs(i).Range.Shading.BackgroundPatternColor = wdColorLightGreen
Next i
Everything is reshaded as expected.
End Sub
Sub SetFinalshading()
Dim objCCs As ContentControls
Dim i As Long
ActiveDocument.Paragraphs(1).Range.Shading.BackgroundPatternColor =
wdColorAutomatic
Set objCCs = ActiveDocument.ContentControls
For i = 1 To objCCs.Count
DoEvents
objCCs(i).Range.Shading.BackgroundPatternColor = wdColorAutomatic
Next i
End Sub
The text is reshaded (shading removed) but the CCs retain the shading
applied previiously.
This seems like a bug to me. Can anyone offer an explaination why the CCs
can be shaded, the shading can be changes, but it can't be changed back to
no shading.
behaviour that appears to be a bug.
Create new document and add a line of text. Go down a few lines and add a
few content controls. Run these three macros in order:
Sub SetInitialShading()
Dim objCCs As ContentControls
Dim i As Long
ActiveDocument.Paragraphs(1).Range.Shading.BackgroundPatternColor =
wdColorLightYellow
Set objCCs = ActiveDocument.ContentControls
For i = 1 To objCCs.Count
DoEvents
objCCs(i).Range.Shading.BackgroundPatternColor = wdColorLightYellow
Next i
End Sub
Everything is shaded as expected.
Sub SetNewShading()
Dim objCCs As ContentControls
Dim i As Long
ActiveDocument.Paragraphs(1).Range.Shading.BackgroundPatternColor =
wdColorLightGreen
Set objCCs = ActiveDocument.ContentControls
For i = 1 To objCCs.Count
DoEvents
objCCs(i).Range.Shading.BackgroundPatternColor = wdColorLightGreen
Next i
Everything is reshaded as expected.
End Sub
Sub SetFinalshading()
Dim objCCs As ContentControls
Dim i As Long
ActiveDocument.Paragraphs(1).Range.Shading.BackgroundPatternColor =
wdColorAutomatic
Set objCCs = ActiveDocument.ContentControls
For i = 1 To objCCs.Count
DoEvents
objCCs(i).Range.Shading.BackgroundPatternColor = wdColorAutomatic
Next i
End Sub
The text is reshaded (shading removed) but the CCs retain the shading
applied previiously.
This seems like a bug to me. Can anyone offer an explaination why the CCs
can be shaded, the shading can be changes, but it can't be changed back to
no shading.