More Bugs in Content Controls?

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.
 
G

Greg Maxey

Jules,

The idea here was to highlight in some way the many CCs dispersed throughout
a document in one shade, alter that shade as the CCs where filled out, and
then remove all shading at save/printout.

We were using the ContentControl_OnExit Event to change the shade when a
user altered the placeholder text. There is an issue in Word that the
On_Exit Event often fires twice erractically which I have already reported
to MS.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top