Highlight all enterable text areas in a template (Word 2007)

L

Louverril

Is there any way to highlight all the rich text content controls in a Word
Template so the user can easily see what he/she needs to enter or what they
have already entered?

The current light grey pre editing text doesn't stand out much and after
editing you can't easily pick out where you have made changes.

I thought of doing something like this (below) but is there an easier way?!!

Sub SetTitleForContentControl()
'use to highlight to be altered/altered text in a template - could add reverse
'on button. Will need to refer to all controls.
Dim objCC As ContentControl
Dim strhighlight As String
strhighlight = "Intense Reference"
Set objCC = ActiveDocument.ContentControls _
.Add(wdContentControlText)
objCC.Title = "Please enter your name"
objCC.DefaultTextStyle = strhighlight

End Sub

Thanks Lou
 
G

Greg Maxey

I suppose you could do something like this:

Sub SetInitialShading()
Dim objCC As ContentControl
For Each objCC In ActiveDocument.ContentControls
objCC.Range.Shading.BackgroundPatternColor = wdColorLightYellow
Next
End Sub

Private Sub Document_ContentControlOnExit(ByVal oCC As ContentControl,
Cancel As Boolean)
If oCC.Range.Text = oCC.PlaceholderText Then
oCC.Range.Shading.BackgroundPatternColor = wdColorLightYellow
Else
oCC.Range.Shading.BackgroundPatternColor = wdColorLightGreen
End If
End Sub
 
L

Louverril

Greg,

Thanks for this.

It sounded great but when I tried to run the following (by using the macro;
run button on Macros)

Sub SetInitialShading()
Dim objCC As ContentControl
For Each objCC In ActiveDocument.ContentControls
objCC.Range.Shading.BackgroundPatternColor = wdColorLightYellow
Next
End Sub

the first content controls background went yellow as expected but then Word
just hung - with the spinning ball (or whatever it's called) and I had to use
task manager to close it down.

Any ideas?

Thanks Lou
 
G

Greg Maxey

Lou,

I can't offer much help. I created a new document, added a dozen or so
content controls, ran the code and it worked fine.

What happens if you try stepping through the code one line at a time (Using
VB editor and the F8 key)
 
L

Louverril

Thanks Greg,

It is not your code - I have tried other for each's as you saw in the
followup question above and I have the same problem.

I stepped thru after creating a breakpoint and it works fine - but i cannot
run it normally.

Really disappointed.

Lou
 

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