![]() |
#1
|
|||
|
|||
![]()
I am using the following code with several other codes in Word 2010. If I do not have any other codes or this one is the first code then it works but as soon as I add others before this one I get the error msg the requested member of the collection does not exist
I am trying to color the background of the drop down box when I select the different items Code:
Option Explicit Dim i As Long Private Sub Document_Open() ActiveDocument.Bookmarks("DropDown").Range.Select Call Index End Sub Sub Index() i = Replace(Selection.FormFields(1).Range.Bookmarks(1).Name, "DropDown", "") End Sub Sub RiskClassification() Dim sText As String, oFld As FormField With ActiveDocument Set oFld = .FormFields("Dropdown" & i) sText = oFld.Result If .ProtectionType <> wdNoProtection Then .Unprotect Password:="" With oFld.Range Select Case sText Case Is = " " 'white .Font.Color = wdColorWhite .Shading.BackgroundPatternColor = wdColorWhite Case Is = "1A" 'red .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorRed Case Is = "2A" 'red .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorRed Case Is = "3A" 'orange .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorOrange Case Is = "4A" 'yellow .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorYellow Case Is = "1B" 'red .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorRed Case Is = "2B" 'orange .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorOrange Case Is = "3B" 'yellow .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorYellow Case Is = "4B" 'blue .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorBlue Case Is = "1C" 'orange .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorOrange Case Is = "2C" 'yellow .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorYellow Case Is = "3C" 'blue .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorBlue Case Is = "4C" 'green .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorGreen Case Is = "1D" 'yellow .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorYellow Case Is = "2D" 'blue .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorBlue Case Is = "3D" 'green .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorGreen Case Is = "4D" 'green .Font.Color = wdColorBlack .Shading.BackgroundPatternColor = wdColorGreen End Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="" End With End Sub Last edited by macropod; 10-08-2015 at 05:17 PM. Reason: Added code tags & formatting |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
vba error method or data member not found in excel 2010 | Rose roon | Excel Programming | 0 | 09-08-2015 03:51 AM |
5941 requested member of collection does not exist Prevents Userform from Showing | marksm33 | Word VBA | 1 | 02-22-2014 08:56 AM |
Outlook 2010 problem (new member) | Cullers | Outlook | 0 | 01-21-2011 10:18 AM |
[PowerPoint 2010] Change font for all slides in an exist *.PPTX file | LongTTH | PowerPoint | 0 | 12-15-2010 02:07 AM |
![]() |
tatihulot | PowerPoint | 1 | 11-16-2010 08:35 AM |