How do content control fields work?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to compile a template document for new proposals and in some
downloaded templates I see the excellent use of Content Control fields. I
want the user to be able to enter the customer name once at the beginning and
for this data to be replicated in the header and other areas of the document
and Content Control seems to be the answer.

But I can't seem to make this work. Anyone know how to reference the
information in a Content Control? The Properties dialog box seems to omit
important info, like the field name for starters ...

All very confusing!!
 
Has Greg added material on Content Controls (new in Word 2007)?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
This article may help to shed some light:

http://blogs.msdn.com/microsoft_office_word/archive/2007/01/10/separate-yet-equal.aspx

--
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"

This message was posted to a newsgroup, Please post replies and questions
to the group so that others can learn as well.
I am trying to compile a template document for new proposals and in some
downloaded templates I see the excellent use of Content Control fields. I
want the user to be able to enter the customer name once at the beginning
and
for this data to be replicated in the header and other areas of the document
and Content Control seems to be the answer.

But I can't seem to make this work. Anyone know how to reference the
information in a Content Control? The Properties dialog box seems to omit
important info, like the field name for starters ...

All very confusing!!
 
Many thanks for this Graham but like Suzanne says, this doesn't actually
answer the question. Forms and bookmarks and the like are all great, but
Content Control which is new in v2007 seems to be exactly what I was looking
for but is not very well documented / seems frustratingly limited.

Is anyone out there able to help explain this feature??
 
Suzanne,

No I haven't. I looked into doing that a few months ago but quit when
I found bum dope in the MSDN technical article on Content Controls.
When first created CCs apparently could have a unique name (or tag).
I suppose through changes in development the name and tag are no
longer unique to the CC. I was hoping this would be corrected (the
article and the issue) before the public release. It wasn't. I am
not at my Word2007 machine right now, but if memory serves the CC has
a unique ID number that you can determine through VBA and then use it
is a reference. I will check tonight and perhaps post some updated
information on my web page.
 
The sites make really good reading thank you. The one main question that I
had was with how to reference a Content Control. A template that I downloaded
had a Content Control for the Title, which was repeated on the next page.
Update one and the other would update.

This is good for existing Property fields, but can we create custom ones? I
want to have users enter the customer name on the front page (into a Content
Control) and to have this information repeated in other areas, but I cannot
for the life of me figure out how to do this.
 
Yes, you can create custom properties. I was shown, but have not had a
chance to work up the steps. Perhaps Graham will get some time this evening.
If he doesn't then I will see what I can come up with. XML is NOT my strong
suit by any stretch of the means. <sigh>

--
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"

This message was posted to a newsgroup, Please post replies and questions
to the group so that others can learn as well.
The sites make really good reading thank you. The one main question that I
had was with how to reference a Content Control. A template that I
downloaded
had a Content Control for the Title, which was repeated on the next page.
Update one and the other would update.

This is good for existing Property fields, but can we create custom ones? I
want to have users enter the customer name on the front page (into a Content
Control) and to have this information repeated in other areas, but I cannot
for the life of me figure out how to do this.
 
Here is one way and I am working on others to update my website:

Use the Document_ContentConrolOnExit event to write the text value of the
current Content Control to a custom document property. Then use DocProperty
fields at the other location in your document to repeat the data:

Private Sub Document_ContentControlOnExit(ByVal currentCC As ContentControl,
Cancel As Boolean)
Dim oDoc As Word.Document
Set oDoc = ActiveDocument
Select Case currentCC.Title
Case "Client_Name"
On Error Resume Next
oDoc.CustomDocumentProperties("Client_Name").Value =
currentCC.Range.Text
If Err.Number = 5 Then
oDoc.CustomDocumentProperties.Add _
Name:="Client_Name", LinkToContent:=False,
Value:=currentCC.Range.Text, _
Type:=msoPropertyTypeString
End If
On Error GoTo 0
Case Else
'Do nothing
End Select
UpdateDocumentFields
End Sub
Sub UpdateDocumentFields()
Dim pRange As Word.Range
Dim iLink As Long
iLink = ActiveDocument.Sections(1).Headers(1).Range.StoryType
For Each pRange In ActiveDocument.StoryRanges
Do
pRange.Fields.Update
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub
 
Greg and I have the same initials, we have been friends for years, we both
have Word related web sites and both bounce ideas off one another - but we
are not the same person ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Is there a way to incorporate the auto-updated content controls without
resorting to VBA or other coding? The templates freely downloaded from Office
Online seem to have these already incorporated, dependent on standard
document properties. It would be nice if I could create these myself, too.
 
Hi again Greg, just read your webpage
http://gregmaxey.mvps.org/Repeating_Data.htm - the following excerpt implies
that I am indeed limited to the built-in (factory default) Document Property
content controls if I want to "repeat data" without coding. Am I right?

"A very simple method of repeating data in a Word2007 document without
knowledge of any XML or VBA is to use the built-in Document Property content
controls. "
 
Pamela,

I still don't claim to be an expert with Content Controls or even a Pioneer.
Let's say a stumbling Pioneer ;-)

You can always bookmark a ContentControl range and use a REF field to that
bookmark. Other than that AFAIK, it is the built-ins with the limit they
carry or some VBA coding. The piece stating with 7.c. is really the way to
go and the coding is relatively simple.
 
Is there a way to incorporate the auto-updated content controls without
resorting to VBA or other coding? The templates freely downloaded from Office
Online seem to have these already incorporated, dependent on standard
document properties. It would be nice if I could create these myself, too.
--
Thanks,
Pamela Denchfield









- Show quoted text -

Pamela,

I experimented today with creating and AddIn that would allow a user
to insert multiple custom mapped CCs seemingly effortless and without
needing to do any VBA or XML coding. I want to refine it a bit before
I post it to my website but if you contact me through the website
feedback I will share it with you now.
 
I appreciate the add-in and look forward to trying it out on my next template
project!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top