Word JS API Header Settings

Occasional Contributor

I'm using the latest version of Word JS API. I need to modify the header, both Primary and First Page, through my add-in.

 

I'm able to create and set the necessary headers. I can confirm this by manually changing the header settings in Word. But I'm unable to set the header settings so that the first page has a different header through my add-in.

 

I saw that the new 1.4. API includes a property headerFooterFirstPageDifferent. How should one use this property and change it?

 

If I try to read the current settings for example like below the headerFooterFirstPageDifferent is always undefined.

// Create a proxy object for the document.
var thisDocument = context.document;

// Get Document Sections
var mySections = thisDocument.sections;
        
// Queue a commmand to load the sections.
 context.load(mySections,'body/style');
        
// Synchronize the document state by executing the queued-up commands, 
// and return a promise to indicate task completion.
return context.sync().then(function () {
 //Get the first and only section on my document
 var curSetting = mySections.items[0].headerFooterFirstPageDifferent;
}

 

0 Replies