views:

40

answers:

1

I'm trying to edit a .docx header through Word Automation. If the Content Controls are placed in the body of the text there is no problem, but if the content controls are in the header or footer I'm not able to target them. Is there any way of targetting Content Controls in the header or footer (using Visual Studio 2008 Express)?

A: 

Using Word Automation one way of targetting ContentControls in the header can be:

        Dim ContControlCollec As Word.ContentControls
    ContControlCollec = WordDoc.Doc.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range.ContentControls

        ContControlCollec.Item(1).Range.Text = Text1
        ContControlCollec.Item(2).Range.Text = Text2
ac55