WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Unable to automate changes in Header/Footer?

 
   Home -> Office -> User Forms RSS
Next:  To rearrange the contents of a table according to..  
Author Message
KPKaltenbach

External


Since: Jul 11, 2008
Posts: 1



(Msg. 1) Posted: Fri Jul 11, 2008 3:22 pm
Post subject: Unable to automate changes in Header/Footer?
Archived from groups: microsoft>public>word>vba>userforms (more info?)

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
Login to vote
Doug Robbins - Word MVP

External


Since: Jul 14, 2006
Posts: 5494



(Msg. 2) Posted: Sun Jul 13, 2008 5:17 pm
Post subject: Re: Unable to automate changes in Header/Footer? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

It is not necessary to protect a document that uses Content Controls. That
is the advantage of them over FormFields

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

<KPKaltenbach DeleteThis @gmail.com> wrote in message
news:a29e2953-7899-4375-a07a-92d34c19d16c@26g2000hsk.googlegroups.com...
> 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
Login to vote
Display posts from previous:   
       Home -> Office -> 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
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
 WinRAR
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET