What version of Word? Have you considered using content controls instead of Formfields?
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim oCC As ContentControl Dim oRng As Word.Range Dim strPW As String strPW = "topics" Select Case ContentControl.Title Case "Subject" 'The "Subject" Dropdown CC in document. If Not ActiveDocument.ProtectionType = wdNoProtection Then ActiveDocument.Unprotect Password:=strPW End If Set oCC = ActiveDocument.SelectContentControlsByTitle("HF Subject").Item(1) 'Richtext CC in Header Select Case True Case ContentControl.ShowingPlaceholderText: oCC.Range.Text = vbNullString Case ContentControl.Range.Text = "MATH" oCC.Range.Text = "Subject: MATH" Set oRng = oCC.Range oRng.Start = oRng.Start + 9 oRng.Font.ColorIndex = wdRed Case ContentControl.Range.Text = "ENGLISH" oCC.Range.Text = "Subject: ENGLISH" Set oRng = oCC.Range oRng.Start = oRng.Start + 9 oRng.Font.ColorIndex = wdBlue Case ContentControl.Range.Text = "SOCIAL STUDIES" oCC.Range.Text = "Subject: SOCIAL STUDIES" Set oRng = oCC.Range oRng.Start = oRng.Start + 9 oRng.Font.ColorIndex = wdGreen End Select 'Richtext CC in Footer ActiveDocument.SelectContentControlsByTitle("HF Subject").Item(2).Range.FormattedText = oCC.Range.FormattedText ActiveDocument.Protect wdAllowOnlyReading, , strPW End Select lbl_Exit: Exit Sub End Sub




Reply With Quote