Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.word.tables
WillW WillW is offline
external usenet poster
 
Posts: 4
Default Conditional Cell Color

Want to hold my hand through one more step? Everything seems to work in its
parts.

The legacy dropdown is located in cell (1,4) of the first table on the page
(there are others lower on the page). I changed the cell reference in the
macro so the same cell changes color. I stepped through the macro, and it
works. I selected the macro to run on Exit (on exiting the dropdown?).

I protected the form and saved it as a .dotm. But the macro is not
triggered when I move from the control (to verify, I set a break point).
Thinking it might be a macro security issue, I "enabled all macros".

More help please.

"Graham Mayor" wrote:

You have to protect the document for forms for legacy fields to work.
You should find http://gregmaxey.mvps.org/Classic%20Form%20Controls.htm
useful.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



WillW wrote:
Thanks, Graham -- It took me a while to get back to this, but I can
see the possibility of its working.

A basic problem for me, though: I can't make the Dropdown1 legacy
control function as a dropdown. It just sits there looking grey with
no hint of a dropdown. When I step through the macro, the background
color changes appropriately (matching the word that happens to be
displayed), but I'm not able to select the color from the legacy
control. And exiting the control doesn't change the color of A1.

What am I doing wrong? (Entering "legacy form control" in Word Help is
useless)

Thanks

"Graham Mayor" wrote:

If you use legacy form fields in your document, as suggested by Doug
in response to your other query, and one of those fields is a
dropdown fiild containing the three values, then you can certainly
format a cell of the table based on the selected content of that
dropdown field by running a macro on exit from the field. The
following, for example, will colour the first cell of the table
.Cell(1, 1) according to the result of the field

Sub ColorCellA1()
Dim sColor As String
Dim bProtected As Boolean
With ActiveDocument
If .ProtectionType wdNoProtection Then
bProtected = True
.Unprotect Password:=""
End If
With .Tables(1).Cell(1, 1).Shading
Select Case
LCase(ActiveDocument.FormFields("Dropdown1").Resul t)
Case Is = "red" .BackgroundPatternColor = wdColorRed
Case Is = "yellow"
.BackgroundPatternColor = wdColorYellow
Case Is = "green"
.BackgroundPatternColor = wdColorGreen
End Select
End With
If bProtected = True Then
.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True, _
Password:=""
End If
End With
End Sub

You may find the examples at
http://www.gmayor.com/word_vba_examples.htm and
http://www.gmayor.com/SelectFile.htm useful.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




WillW wrote:
I saw some other questions regarding conditional formating in Word
tables, so I don't hold out much hope for this. But it seems simple
enough that there might be some relatively easy way to do it.

Here's the situation: In a cell in the top row of a table in my
Word template, only 3 values are possible to select using a
control: Green, Yellow, Red. Can I make Word change the cell fill
color based on the option selected?

I tried using an embedded Excel table, but it just doesn't seem to
be the right solution in this case, and my manager doesn't want to
use Excel for the whole document as I suggested.

Thanks






 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Conditional Formatting" of Word Table Cell MaxArk[_4_] Tables 3 April 30th 23 02:51 AM
How do I change a table cell color globally? CA_stateworker Tables 3 March 14th 09 06:10 AM
Word 2007 table cell color selection Dick De Vries Tables 7 May 16th 07 04:22 PM
Custom Table Style-Background Cell Color jilltwfl Tables 1 March 16th 07 12:03 AM
Need to add fill color to a table cell Jen G Tables 2 November 30th 04 05:31 PM


All times are GMT +1. The time now is 12:30 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"