Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2008

Tip: Looking for answers? Try searching our database.

Change Color

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Debra Ann - 07 Feb 2008 12:29 GMT
I have a table cell with a drop down field with four options (good, caution,
problem, fix).  Depending on the user's pick, I want the table cell to change:

If good then green
If caution, then yellow
etc.

What is the code to do this?
Signature

Debra Ann

Debra Ann - 07 Feb 2008 13:27 GMT
Sorry, I meant to say ... I want the table cell "color" to change.
Signature

Debra Ann

> I have a table cell with a drop down field with four options (good, caution,
> problem, fix).  Depending on the user's pick, I want the table cell to change:
[quoted text clipped - 4 lines]
>
> What is the code to do this?
Greg Maxey - 07 Feb 2008 21:44 GMT
Something like this:

Option Explicit
Public mstrFF As String

'Run on exit from your DD field

Public Sub AOnExit()
Dim oDoc As Word.Document
Dim oCell As Cell
Set oCell = ActiveDocument.Tables(1).Cell(1, 1)
Set oDoc = ActiveDocument
oDoc.Unprotect
With GetCurrentFF
 Select Case .Name
   Case Is = "MyDropDown"
     Select Case .Result
       Case Is = "good"
         oCell.Shading.BackgroundPatternColor = wdColorGreen
       Case Is = "caution"
         oCell.Shading.BackgroundPatternColor = wdColorYellow
       Case Else
         'Whatever
     End Select
   Case Else
     'Whatever
 End Select
End With
oDoc.Protect wdAllowOnlyFormFields, True
End Sub

Public Function GetCurrentFF() As Word.FormField
With Selection
 If .FormFields.Count = 1 Then
   Set GetCurrentFF = .FormFields(1)
 ElseIf .FormFields.Count = 0 And .Bookmarks.Count > 0 Then
    Set GetCurrentFF = ActiveDocument.FormFields _
    (.Bookmarks(.Bookmarks.Count).Name)
 End If
End With
End Function

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> I have a table cell with a drop down field with four options (good,
> caution, problem, fix).  Depending on the user's pick, I want the
[quoted text clipped - 5 lines]
>
> What is the code to do this?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.