From: Irfan Shaikh (irfan.shaikh on
Use Document.Sections(1).Headers(WdHeaderFooterIndex.wdHeaderFooterPrimary)

That will give you headerfooters collection

loop it and check with ISHeader property false in order to get footer
you can get range object from HeaderFooter object

Add content control to its range

CC =
HeaderFooter.Range.ContentControls.Add(WdContentControlType.wdContentControlDate, HeaderFooter.Range)

Thanks,

Irfan Shaikh

"Srinivas" wrote:

> Hi All,
>
> I programmatically insert a plain text content control in a footer with
> below code.
>
>
> Microsoft.Office.Interop.Word.Document wordDocument =
> application.Documents.Open( ref fileName, ref objFalse, ref objReadOnly, ref
> objFalse, ref objMissing,
> ref objMissing, ref objFalse,
> ref objMissing, ref objMissing, ref objMissing,
> ref objMissing, ref
> ObjVisible, ref objFalse, ref objMissing, ref objTrue,
> ref objMissing ) as
> DocumentClass;
>
> //cursor is focused some where in Footer before I call this code.
> object range = wordDocument.ActiveWindow.Selection.Range;
> ContentControl cc =
> wordDocument.ContentControls.Add(WdContentControlType.wdContentControlText,
> ref range);
> cc.Tag = "myContentControl"
>
>
> Here wordDocument.ContentControls.Add() returns a content control without
> adding it to the wordDocument.ContentControls collection.
> The wordDocument.ContentControls.Count remains same before and after.
>
> Strangely, I could see the same conten control in the collection with the
> following code:
>
> ContentControls ccs =
> wordDocument.SelectContentControlsByTag("myContentControl");
>
>
>
> As I need to iterate wordDocument.ContentControls in different parts of my
> application for all content controls (without bothering about tag)in the
> document,
>
> Could you please suggest me how I can add it(CC in footer) to
> wordDocument.ContentControls or a collection where I can retrieve it later.
>
> Thank in Advance,
> Srinivas
> ps: I have same problem inserting a content control in a Text Field.