Re: Insert text into a content control



That's why I think it is best to work with the unique CC ID.

Each CC also has a unique ID number. You can get the number by selecting
the CC and run this code:

Sub GetCCID()
MsgBox Selection.Range.ContentControls(1).ID
End Sub

Then you can work with that unique CC using:

Sub Test()
ActiveDocument.ContentControls("##########").Range.Text = "Whatever text you
want the CC to show"
End Sub


nostabo wrote:
Thanks, Greg. But the next question is where do I find the CC's
index? It doesn't seem to be revealed in the "Properties" dialog. I
know that I can guess, but with 30 + CCs it could get tough to
remember them all.

"Greg Maxey" wrote:

ContentControls are indexed in the document. So

Sub Test()
ActiveDocument.ContentControls(3).Range.Text = "I'm CC index number
3"
End Sub

Each CC also has a unique ID number. You can get the number by
selecting the CC and run this code:

Sub GetCCID()
MsgBox Selection.Range.ContentControls(1).ID
End Sub

Then you can work with that unique CC using:

Sub Test()
ActiveDocument.ContentControls("##########").Range.Text = "Whatever
text you want the CC to show"
End Sub

Where "##########" is the unique ten digit ID.



--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org


"nostabo" <nostabo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:EFDD4934-B451-47BF-B312-6B04CDF92C01@xxxxxxxxxxxxxxxx
I'm trying to automate the insertion of text into contracts using
Word 2007.
I can do it with the legacy controls, but the new text content
control won't
seem to do it.

The code that works for the legacy controls is:
ActiveDocument.FormFields("txtContractName").Result =
txtContractName.Text

Where the txtContractName that supplies the value is on a form.

I'd like to use the more "modern" control. Is it possible?

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org



.



Relevant Pages

  • Re: Word 2003 - set compatability option
    ... without such juggling, however the following macro saved in normal.dot ... Sub AutoOpen() ... Word MVP web site http://word.mvps.org ...
    (microsoft.public.word.docmanagement)
  • Re: Watermark macro
    ... Word MVP web site http://word.mvps.org ... Sub Macropicture() ... Selection.ShapeRange.Left = wdShapeCenter ...
    (microsoft.public.word.vba.general)
  • Re: XP Office corruptions
    ... Sub PasteUnfText() ... Macro is created. ... Word MVP web site http://word.mvps.org ...
    (microsoft.public.word.customization.menustoolbars)
  • Re: outline toolbar
    ... Sub ViewOutlineMaster() ... Word MVP web site http://word.mvps.org ... switch off the toolbar when Outline view is selected. ...
    (microsoft.public.word.docmanagement)
  • Re: using macros on custom toolbars
    ... Graham Mayor - Word MVP ... Word MVP web site http://word.mvps.org ... Sub AutoClose() ...
    (microsoft.public.word.vba.general)