Hello, I have created a document template for a client which basically consists of a user form (using the new Content Controls in 2007) which their users will fill out (dates, addresses, etc.) and use for correspondence from their office with their clients. The tricky part is that they want certain data to be repeated in the header from the second page on.
So, I've placed the appropriate content controls in the header, and written a macro which updates each of the content controls in that header whenever the user tabs away from a content control. It works great.... the problem is that the second I protect the document, it stops working, claiming the area you are trying to edit is protected. So, even though they are form fields, because they exist in the header, they are considered protected. I've attempted to setup multiple sections and remove protection for the sections the header falls under, but to no avail.
Here is the code for the macro in case anyone is interested:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
'Variable Declarations
Dim objCC As ContentControl
Dim strDate As String
Dim strRecipient As String
Dim strOrg As String
'Captures the text input from the user.
For Each objCC In ActiveDocument.ContentControls
If objCC.Tag = "Date" Then
strDate = objCC.Range.Text
ElseIf objCC.Tag = "Recipient" Then
strRecipient = objCC.Range.Text
ElseIf objCC.Tag = "Organization" Then
strOrg = objCC.Range.Text
End If
Next
'Saves the text entered by the user from the first page to the header for following pages.
For Each objCC In ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.ContentControls
If objCC.Tag = "hdrDate" Then
objCC.Range.Text = strDate
ElseIf objCC.Tag = "hdrRecipient" Then
objCC.Range.Text = strRecipient
ElseIf objCC.Tag = "hdrOrg" Then
objCC.Range.Text = strOrg
End If
Next
End Sub
Please, if anyone can offer me any ideas or assistance, it would be greatly appreciated! Thanks!