![]() |
|
#1
|
|||
|
|||
![]()
The code runs here without error:
Is your password "Password" Unless you are using formfields, there is no point in protecting for filling in forms. See: http://gregmaxey.com/word_tip_pages/...llin_form.html and the section "Restrict Editing" Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim StrPwd As String StrPwd = "Password" With ContentControl If Len(.Title) < 4 Then Exit Sub If Left(.Title, 4) = "SHR1" Then If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect Password:=StrPwd Select Case .Range.Text Case "Red": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdRed Case "Yellow": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdYellow Case "Green": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdBrightGreen Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight End Select ActiveDocument.Protect wdAllowOnlyFormFields, True, StrPwd End If If Left(.Title, 4) = "SHR2" Then If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect Password:=StrPwd Select Case .Range.Text Case "Red": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdRed Case "Yellow": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdYellow Case "Green": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdBrightGreen Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight End Select ActiveDocument.Protect wdAllowOnlyFormFields, True, StrPwd End If End With End Sub |
#2
|
||||
|
||||
![]()
That's not the only useful scenario. It functions the same way with content controls, too (i.e. they remain accessible, but the remainder of the document is inaccessible). That may suit the designer's purposes better than read-only restrictions with a plethora of exceptions.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Tags |
color, dropdown, reaction |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
block selection in dropdown list | Intruder | Excel | 2 | 01-10-2013 10:20 AM |
![]() |
coconutt | Word VBA | 5 | 09-13-2012 05:23 PM |
![]() |
fedcco | Excel | 12 | 08-28-2012 10:43 PM |
![]() |
biffle0764 | Word | 2 | 05-09-2012 12:54 PM |
Change cell color everytime a value is selected in dropdown list | angelica_gloria | Excel | 4 | 01-27-2012 06:47 PM |