Help!

Unable to automate changes in Header/Footer?

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> User Forms RSS
Next:  Help, I deleted a Custom Command . . how do I get..  
Author Message
KrisPK



Joined: Jul 11, 2008
Posts: 1



PostPosted: Fri Jul 11, 2008 5:53 pm    Post subject: Unable to automate changes in Header/Footer?

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!
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> User Forms All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum