Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking

    Iím using Word 2007 and I have Drop-Down Form Fields in my .docm that when you make a selection from the list it will also change the fill color, like conditional formatting in Excel . What Iím trying to achieve here is, the colors I have in this code are the right colors but they are too bright. Is there a way to soften them up, like a pastel?

    Code:
    Sub ColourIt()
    Dim Pwd As String, Tint
    Pwd = ""
    With ActiveDocument
      .Unprotect (Pwd)
      Select Case .FormFields(fFld).Result
    	Case "Inspected"
    	  Tint = 4
    	Case "Not Inspected"
    	  Tint = 16
    	Case "Not Present"
    	  Tint = 3
    	Case "Damaged/Repair Needed"
    	  Tint = 7
    	Case "Safety Hazard"
    	  Tint = 6
      End Select
      .Tables(1).Cell(tRow, tCol).Range.Shading.BackgroundPatternColorIndex = Tint
      .Protect wdAllowOnlyFormFields, Noreset:=True, Password:=Pwd
    End With
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The number of colors available through BackgroundPatternColorIndex is limited. You can use BackgroundPatternColor instead, which lets you use any RGB color, e.g. RGB(255,255,224) for a soft yellow, RGB(224,255,224) for a soft green etc.

    So in the Select Case part you'd use code such as

    Code:
    	Case "Inspected"
    	  Tint = RGB(224, 255, 224)
    and later on

    Code:
      .Tables(1).Cell(tRow, tCol).Range.Shading.BackgroundPatternColor = Tint

  3. #3
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='785632' date='21-Jul-2009 11:21']The number of colors available through BackgroundPatternColorIndex is limited. You can use BackgroundPatternColor instead, which lets you use any RGB color, e.g. RGB(255,255,224) for a soft yellow, RGB(2224,255,224) for a soft green etc.

    So in the Select Case part you'd use code such as

    Code:
    	Case "Inspected"
    	  Tint = RGB(224, 255, 224)
    and later on

    Code:
      .Tables(1).Cell(tRow, tCol).Range.Shading.BackgroundPatternColor = Tint
    [/quote]
    Hi HansV
    Thank you I will give it a try.....

  4. #4
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='ababenchrist' post='785633' date='21-Jul-2009 11:23']Hi HansV
    Thank you I will give it a try.....[/quote]
    I applied the new code with newly select RGB color 171, 229, 123. but only got error code 5941 "The requested member of the collection does not exist.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Perhaps something has changed in Word 2007 (which I don't have). You might attach a copy of your document (with sensitive info removed) so that Loungers can investigate it.

  6. #6
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='785641' date='21-Jul-2009 11:57']Perhaps something has changed in Word 2007 (which I don't have). You might attach a copy of your document (with sensitive info removed) so that Loungers can investigate it.[/quote]
    Hi Hanv
    I Apologize I had to save and close first. After re-opening it works great.
    Thank you so much

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Great! You're welcome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •