Code attached to a table cell?

L

LL

Is it possible to attach some VB code to a cell of a table?

What I'm thinking about is that I need to 'shade' the cell according to the
content of the cell:

If cellcontents = "One" then shading = red
If cellcontents = "Two" then shading = amber
If cellcontents = "Three" then shading = green

I have no idea how to do this (or if it is possible).

Thanks.
 
J

Jonathan West

LL said:
Is it possible to attach some VB code to a cell of a table?

What I'm thinking about is that I need to 'shade' the cell according to
the
content of the cell:

If cellcontents = "One" then shading = red
If cellcontents = "Two" then shading = amber
If cellcontents = "Three" then shading = green

I have no idea how to do this (or if it is possible).

The short answer is that to do this you use Excel, which has facilities for
conditional formatting in just this way.

If you must use Word, then you can easily enough write a macro to apply
appropriate shading to a cell. What is much more difficult is to cause the
shading to be applied automatically without any specific intervention on
your part. I won't say that this is completely impossible, but Word is not
designed for it. Just create a keyboard shortcut or toolbar button that runs
your macro on the currently select table cell.
 
H

Helmut Weber

Hi LL,

it is not worth the effort.

You may use a selection-change-event,
check whether you are in a table,
chck what cell you are in,
check for the cell's value,
and apply a shading accordingly.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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