Change color in table cell from control buttons

J

jay

I have a table with multiple rows and columns. One cell is labeled status
and then it has an adjoining cell next to it where I want that cell to change
to red, yellow, green based on a prior selection somewhere in the document.
I have an area at the bottom that has three control buttons button1 = "help"
(if selected it should change that cell at the top red, button2 = "problems"
(if selected change the same cell mentioned above to yellow) and button3 ="on
schedule (if selected the same cell above turns to green. I am having a hard
time of how to select that particular cell, and how to change colors -
ugh.... please help.
 
J

Jezebel

Along the lines of

MyTable.Cells(3,2).Shading.BackgroundPatternColor = wdColorRed

How you set the reference to the table (MyTable) depends on how your code
works; which you haven't explained.
 
J

jay

Sorry, I did not have any code written but I have provided a picture of the
environment. I just have three control buttons as explained earlier - there
is no code written. I have the idea that I can attach a macro to button and
then use some command of "onclick" or something like that. I appreciate the
nudge in the right direction.
 
J

Jezebel

If there's only one table in the document you could use

ActiveDocument.Tables(1).Cells(...
 
J

jay

I know it was all kind of basic but I appreciate your help - with some
experimenting around from your initial direction I was able to hammer it out.
 
R

Rookie_User

OK, my requirements have kind of changed a little. I currently have a table,
lets say 3x3 and in cell 3x1 there is a graphic circle (I just drew a
circle). I would like to change the fill color of that graphic.

I have been using this code: which works but I no longer want to change the
cell color - just the fill color of the graphic but I don't know how to grab
it.

Private Sub CheckBox1_Click()
Dim outerTable As Table
Dim outerCell As Cell
Set outerTable = ActiveDocument.Tables(1)
Set outerCell = outerTable.Cell(2, 2)
outerCell.Range.Text = "It worked"
outerCell.Shading.BackgroundPatternColor = wdColorRed
End Sub
 

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