View Single Post
  #13   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 285
Default How do content control fields work?

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.


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Pamela Denchfield wrote:
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. "

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


"Greg Maxey" wrote:

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.StoryT ype
For Each pRange In ActiveDocument.StoryRanges
Do
pRange.Fields.Update
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


piersonal wrote:
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.