Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.formatting.longdocs
mfitz
 
Posts: n/a
Default Is there a way to get color to appear when you click in a cell in an MS Word 2003 table?

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.

  #2   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Jezebel
 
Posts: n/a
Default Is there a way to get color to appear when you click in a cell in an MS Word 2003 table?

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



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


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

Thank you for the assistance. Unfortunately, I must say I am not sure
how to find the "ThisDocument module of the template". If someone
could help me get there, that would be terrific.

However, for a little more detail, here is what I am trying to do:

There is a table that has rows of comments and/or questions. Next to
each comment or question are 3 columns with the headers "Green"
"Yellow" "Red", in that order (1 per column). What we are trying to do
is have the color of the cell change to the heading color of that
particular column once someone clicks on it.

Thank you for any and all help you can offer.

Mary


Jay Freedman wrote:
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.



  #5   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?

Hi Mary,

Step by step:

1. I assume you're working in a document (a file whose name has a .doc
extension). Use the File Save As command and set the "Save as type"
box at the bottom of the dialog to "Document Template (*.dot)". The
folder automatically changes to your Templates folder. Save the
template there with an appropriate name.

2. Press Alt+F11 to open the macro editor. On the left side there
should be a pane with a tree view showing the open templates (if not,
click View Project Explorer). One of the icons in the tree will be
labeled with the name of the template.

3. Expand the icon for the template (click the little plus sign next
to it if necessary). There will be a sub-item labeled Microsoft Word
Objects and, under that, one labeled ThisDocument. Double-click the
ThisDocument icon. You should get a large empty pane to the right.

4. Copy the following code (which I've altered to match the behavior
you described) and paste it into the large empty pane.

5. Save the template and close it.

6. Click File New. If you get a task pane on the right, choose
Templates On My Computer. Find the template in the list and
double-click it to make a new document based on the template. Clicking
in any cell in the last three columns of the table will change the
background color from blank to the proper color for that column, and
clicking it again will change it back to blank.

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 three columns
Select Case .ColumnIndex
Case Sel.Tables(1).Columns.Count - 2:
' green
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdBrightGreen
End If
Case Sel.Tables(1).Columns.Count - 1:
' yellow
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdYellow
End If
Case Sel.Tables(1).Columns.Count:
'red
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdRed
End If
End Select
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 5 Jul 2006 08:00:45 -0700, "mfitz" wrote:

Thank you for the assistance. Unfortunately, I must say I am not sure
how to find the "ThisDocument module of the template". If someone
could help me get there, that would be terrific.

However, for a little more detail, here is what I am trying to do:

There is a table that has rows of comments and/or questions. Next to
each comment or question are 3 columns with the headers "Green"
"Yellow" "Red", in that order (1 per column). What we are trying to do
is have the color of the cell change to the heading color of that
particular column once someone clicks on it.

Thank you for any and all help you can offer.

Mary


Jay Freedman wrote:
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.




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

Jay,

Thank you so much! The macro works like a charm!

Mary


Jay Freedman wrote:
Hi Mary,

Step by step:

1. I assume you're working in a document (a file whose name has a .doc
extension). Use the File Save As command and set the "Save as type"
box at the bottom of the dialog to "Document Template (*.dot)". The
folder automatically changes to your Templates folder. Save the
template there with an appropriate name.

2. Press Alt+F11 to open the macro editor. On the left side there
should be a pane with a tree view showing the open templates (if not,
click View Project Explorer). One of the icons in the tree will be
labeled with the name of the template.

3. Expand the icon for the template (click the little plus sign next
to it if necessary). There will be a sub-item labeled Microsoft Word
Objects and, under that, one labeled ThisDocument. Double-click the
ThisDocument icon. You should get a large empty pane to the right.

4. Copy the following code (which I've altered to match the behavior
you described) and paste it into the large empty pane.

5. Save the template and close it.

6. Click File New. If you get a task pane on the right, choose
Templates On My Computer. Find the template in the list and
double-click it to make a new document based on the template. Clicking
in any cell in the last three columns of the table will change the
background color from blank to the proper color for that column, and
clicking it again will change it back to blank.

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 three columns
Select Case .ColumnIndex
Case Sel.Tables(1).Columns.Count - 2:
' green
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdBrightGreen
End If
Case Sel.Tables(1).Columns.Count - 1:
' yellow
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdYellow
End If
Case Sel.Tables(1).Columns.Count:
'red
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdRed
End If
End Select
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 5 Jul 2006 08:00:45 -0700, "mfitz" wrote:

Thank you for the assistance. Unfortunately, I must say I am not sure
how to find the "ThisDocument module of the template". If someone
could help me get there, that would be terrific.

However, for a little more detail, here is what I am trying to do:

There is a table that has rows of comments and/or questions. Next to
each comment or question are 3 columns with the headers "Green"
"Yellow" "Red", in that order (1 per column). What we are trying to do
is have the color of the cell change to the heading color of that
particular column once someone clicks on it.

Thank you for any and all help you can offer.

Mary


Jay Freedman wrote:
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.



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

I hate to say it, but as wonderful as the macro is, no one else can see
it.

I am able to open up the document on my computer, but when I try to
send it on to others, for some reason the coding doesn't get sent along
with it. The other users just see the initial document, and no color
changes occur.

Is there something I may have missed that would cause this?

Thank you again,
Mary


Jay Freedman wrote:
Hi Mary,

Step by step:

1. I assume you're working in a document (a file whose name has a .doc
extension). Use the File Save As command and set the "Save as type"
box at the bottom of the dialog to "Document Template (*.dot)". The
folder automatically changes to your Templates folder. Save the
template there with an appropriate name.

2. Press Alt+F11 to open the macro editor. On the left side there
should be a pane with a tree view showing the open templates (if not,
click View Project Explorer). One of the icons in the tree will be
labeled with the name of the template.

3. Expand the icon for the template (click the little plus sign next
to it if necessary). There will be a sub-item labeled Microsoft Word
Objects and, under that, one labeled ThisDocument. Double-click the
ThisDocument icon. You should get a large empty pane to the right.

4. Copy the following code (which I've altered to match the behavior
you described) and paste it into the large empty pane.

5. Save the template and close it.

6. Click File New. If you get a task pane on the right, choose
Templates On My Computer. Find the template in the list and
double-click it to make a new document based on the template. Clicking
in any cell in the last three columns of the table will change the
background color from blank to the proper color for that column, and
clicking it again will change it back to blank.

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 three columns
Select Case .ColumnIndex
Case Sel.Tables(1).Columns.Count - 2:
' green
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdBrightGreen
End If
Case Sel.Tables(1).Columns.Count - 1:
' yellow
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdYellow
End If
Case Sel.Tables(1).Columns.Count:
'red
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdRed
End If
End Select
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 5 Jul 2006 08:00:45 -0700, "mfitz" wrote:

Thank you for the assistance. Unfortunately, I must say I am not sure
how to find the "ThisDocument module of the template". If someone
could help me get there, that would be terrific.

However, for a little more detail, here is what I am trying to do:

There is a table that has rows of comments and/or questions. Next to
each comment or question are 3 columns with the headers "Green"
"Yellow" "Red", in that order (1 per column). What we are trying to do
is have the color of the cell change to the heading color of that
particular column once someone clicks on it.

Thank you for any and all help you can offer.

Mary


Jay Freedman wrote:
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.



  #8   Report Post  
Posted to microsoft.public.word.formatting.longdocs
John McGhie [MVP - Word and Word Macintosh] John McGhie [MVP - Word and Word Macintosh] is offline
external usenet poster
 
Posts: 506
Default Is there a way to get color to appear when you click in acell in an MS Word 2003 table?

Hi Mary:

Yes, there's a way to do it. However, in these days of antivirus madness,
it is likely to cause more problems than its worth.

All you need to do is copy the macro into the document before you send it.
Look up Organizer in the Help to see how.

Expect a riot of alarms from the virus program on your computer, on your
mail server, on their mail server, and on the recipient's computer if you
do.

If you email the document, you will need to zip it to have any chance of
making it through the virus wall.

Are you sure coloured clicks are worth the trouble? :-)

Cheers


On 7/7/06 5:48 AM, in article
, "mfitz"
wrote:

I hate to say it, but as wonderful as the macro is, no one else can see
it.

I am able to open up the document on my computer, but when I try to
send it on to others, for some reason the coding doesn't get sent along
with it. The other users just see the initial document, and no color
changes occur.

Is there something I may have missed that would cause this?

Thank you again,
Mary


Jay Freedman wrote:
Hi Mary,

Step by step:

1. I assume you're working in a document (a file whose name has a .doc
extension). Use the File Save As command and set the "Save as type"
box at the bottom of the dialog to "Document Template (*.dot)". The
folder automatically changes to your Templates folder. Save the
template there with an appropriate name.

2. Press Alt+F11 to open the macro editor. On the left side there
should be a pane with a tree view showing the open templates (if not,
click View Project Explorer). One of the icons in the tree will be
labeled with the name of the template.

3. Expand the icon for the template (click the little plus sign next
to it if necessary). There will be a sub-item labeled Microsoft Word
Objects and, under that, one labeled ThisDocument. Double-click the
ThisDocument icon. You should get a large empty pane to the right.

4. Copy the following code (which I've altered to match the behavior
you described) and paste it into the large empty pane.

5. Save the template and close it.

6. Click File New. If you get a task pane on the right, choose
Templates On My Computer. Find the template in the list and
double-click it to make a new document based on the template. Clicking
in any cell in the last three columns of the table will change the
background color from blank to the proper color for that column, and
clicking it again will change it back to blank.

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 three columns
Select Case .ColumnIndex
Case Sel.Tables(1).Columns.Count - 2:
' green
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdBrightGreen
End If
Case Sel.Tables(1).Columns.Count - 1:
' yellow
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdYellow
End If
Case Sel.Tables(1).Columns.Count:
'red
If .Shading.BackgroundPatternColorIndex wdAuto Then
.Shading.BackgroundPatternColorIndex = wdAuto
Else
.Shading.BackgroundPatternColorIndex = wdRed
End If
End Select
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 5 Jul 2006 08:00:45 -0700, "mfitz" wrote:

Thank you for the assistance. Unfortunately, I must say I am not sure
how to find the "ThisDocument module of the template". If someone
could help me get there, that would be terrific.

However, for a little more detail, here is what I am trying to do:

There is a table that has rows of comments and/or questions. Next to
each comment or question are 3 columns with the headers "Green"
"Yellow" "Red", in that order (1 per column). What we are trying to do
is have the color of the cell change to the heading color of that
particular column once someone clicks on it.

Thank you for any and all help you can offer.

Mary


Jay Freedman wrote:
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
oups.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.




--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410

Reply
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
Word 97 in Windows XP to maintain formatting Charlie''s Word VBA questions Microsoft Word Help 22 May 20th 23 08:51 PM
take yet another lesson from wordperfect "reveal codes" wordperfect is superior Microsoft Word Help 5 May 11th 09 07:58 PM
I need to extend a table in word (click last cell?) wesjemmett Tables 1 June 28th 06 01:08 PM
Word should allow to 'divide' page by 3 or 4, not just 2 CandasK Page Layout 2 February 28th 06 11:16 PM
WP merge file to Word sstires Tables 4 February 14th 06 07:26 PM


All times are GMT +1. The time now is 12:16 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"