PDA

View Full Version : hide text in front of content control when it is blank



freedemi83
10-10-2013, 03:57 AM
Hi,
I try to figure a ms word forms document in word 2007.
I use content controls, bookmarks and activex controls.
I have a checkbox in the beginning of the document and i want when the user click it, the vba code to check all the content controls to see if they are blank and int positive case to hide the content controls with the texts which is in front of them.
For that case i use this code
--------------------------------------------------------
Private Sub checked_click()
Dim cc As ContentControl
' Dim cb As Bookmarks
If checked.Value = True Then

For Each cc In ActiveDocument.ContentControls
If cc.ShowingPlaceholderText = True Then
cc.Range.Font.ColorIndex = wdWhite
Bookmarks("kataskevastis").Range.Font.Hidden = False
End If
Next
else

For Each cc In ActiveDocument.ContentControls
If cc.ShowingPlaceholderText Then
cc.Range.Font.ColorIndex = wdauto
Bookmarks("kataskevastis").Range.Font.Hidden = True

End If
Next
End If
end sub
-------------------------------------------------------
The problem is that the content controls for these cases works great, but the bookmark field (which consist the content control) is hidden in these cases
and i want to not hidden if the user type in the cc.
Thanks in advance.

Doug Robbins
10-13-2013, 05:27 PM
Use:


Dim cc As ContentControl
With ActiveDocument
For Each cc In .ContentControls
If cc.range.Text = cc.PlaceholderText Then
cc.range.Paragraphs(1).range.Font.Hidden = True
End If
Next cc
End With