Not able to bind content control if I put a content control in footer or header.

Hi,

i have created app for office 2013 and created a content control in the document.

i first bind the content control while initializing the app.

where is code for binding.

  Office.context.document.bindings.addFromNamedItemAsync(controlName, Office.BindingType.Text, { id: controlName + 'Binding' }, function (asyncResult) {
            if (asyncResult.status == Office.AsyncResultStatus.Failed) {
                //showNotificationAlert(controlName + ' Control not Found!', asyncResult.error.message);
            }
        });

But the problem is, when i create another same content control with different name in the footer or header it does not binds  the "Navn" content control which is in the main content of the document. also does not bind the control which is in the footer.

but i don't have any other control with the same name like ABC.

How can i bind content controls in footer or header?

can anyone please help me.

Thanks in Adva

February 24th, 2014 10:10am

Why would you want a content control in the header or footer anyway? They're not readily accessible for data entry there. If all you're trying to do is to replicate the content, you can do that via a StyleRef field. Simply apply a unique Style name to the content control range, then use the StyleRef field in the header/footer to reference that Style's name.
Free Windows Admin Tool Kit Click here and download it now
February 24th, 2014 9:04pm

Hi Paul,

I want to add the company's name dynamically from my App, to the footer. 

User just click's a button in app and the content in footer should automatically fills. this is my requirement.

and as i am working in office for app and i have only java script code. 

Can you please tell me how can i do this by StyleRef field, which you are talking.

Many thanks.

February 25th, 2014 2:59am

If all you want to do is to add something to the header, you don't need a content control - you can add it directly. StyleRef fields are used to replicate content that is in the body of the document. See Word's Help file, or insert|Quick Parts|Field>StyleRef, for details.
Free Windows Admin Tool Kit Click here and download it now
February 25th, 2014 3:25am

Paul,

I don't want to add it directly by selecting field. I want to do it through code (Javascript).Any idea how can I do it?

February 25th, 2014 3:33am

I did not suggest you should do it directly "by selecting field". Here's some VBA code (I don't know JavaScript) for populating a header directly:

Sub Demo()
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "Hello world"
End Sub

As you can see, it's quite simple and no fields or content controls are involved, whether selected or othe

Free Windows Admin Tool Kit Click here and download it now
February 25th, 2014 3:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics