N
Newt
Is it possible to format a cell in a table as soon as a user starts entering
text? Here's what I'd like:
1. Cell starts with no text and has light yellow background
2. User begins typing, which turns the background white
Basically, I'd like something the same as conditional formatting in Excel
(embedding a spreadsheet is not an option).
Here's what I was trying, but it doesn't work:
Private Sub celltext()
If ActiveDocument.Tables(2).Cell(1, 2).Range.Text = "" Then
ActiveDocument.Tables(2).Cell(1, 2).Shading.BackgroundPatternColor =
wdColorLightYellow
Else
ActiveDocument.Tables(2).Cell(1, 2).Shading.BackgroundPatternColor =
wdColorWhite
End If
End Sub
I see two problems. One, I can't seem to get it to read the text in the cell
and two, I don't think that starting to type in a cell is a trigger to
activate the code. Any ideas?
text? Here's what I'd like:
1. Cell starts with no text and has light yellow background
2. User begins typing, which turns the background white
Basically, I'd like something the same as conditional formatting in Excel
(embedding a spreadsheet is not an option).
Here's what I was trying, but it doesn't work:
Private Sub celltext()
If ActiveDocument.Tables(2).Cell(1, 2).Range.Text = "" Then
ActiveDocument.Tables(2).Cell(1, 2).Shading.BackgroundPatternColor =
wdColorLightYellow
Else
ActiveDocument.Tables(2).Cell(1, 2).Shading.BackgroundPatternColor =
wdColorWhite
End If
End Sub
I see two problems. One, I can't seem to get it to read the text in the cell
and two, I don't think that starting to type in a cell is a trigger to
activate the code. Any ideas?