View Single Post
  #3   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Is there a way to get color to appear when you click in a cell in an MS Word 2003 table?

Another way is to write a DocumentSelectionChange event procedure in
the template for the checklist. You haven't said what the "correct
color" is, or how to decide which color is "correct", so I can't
provide an exact solution. Here's an example, though. Put this code in
the ThisDocument module of the template and see how it works. Then you
can modify the logic in the event procedure, or post back and explain
exactly what you want to happen and we can write the code.

Option Explicit

Private WithEvents wdApp As Word.Application

Private Sub Document_New()
'assign Word to the application variable
If wdApp Is Nothing Then
Set wdApp = ThisDocument.Application
End If
End Sub

Private Sub Document_Open()
'assign Word to the application variable
If wdApp Is Nothing Then
Set wdApp = ThisDocument.Application
End If
End Sub

Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection)
' get out as fast as possible if not in table
If Not Sel.Information(wdWithInTable) Then Exit Sub

With Sel.Cells(1)
' work only on the rightmost column
If .ColumnIndex = Sel.Tables(1).Columns.Count Then
' shade it pink if value is negative, otherwise green
If (.Range.Characters(1) = "-") Or _
(.Range.Characters(1) = "(") Then
.Shading.BackgroundPatternColorIndex = wdRed
Else
.Shading.BackgroundPatternColorIndex = wdBrightGreen
End If
End If
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 1 Jul 2006 09:52:32 +1000, "Jezebel"
wrote:

You could put a macrobutton field in each field, attached to a macro that
changes the cell color. But it seems a lot of work for not much benefit.


"mfitz" wrote in message
roups.com...
I am trying to help a colleague with a checklist they have created in
Microsoft Word 2003. We are trying to color code the table so that
when the document is opened, all the cells are clear (empty), but when
someone clicks in a particular cell of a table, the correct color shows
up. Is there a way to get color to appear when you click in a cell in
an MS Word 2003 table?

Thank you for your help.