How to insert Header and footer data with insertooxml

Vinod Kumar 6 Reputation points
2022-06-08T16:59:38.477+00:00

I have open xml file, which has Body data, Header data and Footer data. I am trying to insert data with

context.document.body.insertOoxml(WORD_DATA, "Start"); //WORD_DATA is in XML string  
  
Or  
  
 Office.context.document.setSelectedDataAsync(WORD_DATA,{coercionType:Office.CoercionType.Ooxml},(res)=>{  
         console.log(res);  
 })  

In both cases body data only inserting but not Header and footer. How to extract Header and Footer in the respective sections

I tried this also

 var myFooter = mySections.items[0].getFooter(Word.HeaderFooterType.primary);  
              
 myFooter.insertOoxml(WORD_DATA, Word.InsertLocation.end);  

In this case also inserting Body data only. How to insert Header and Footer data from XML string

Microsoft 365 and Office | Development | Office JavaScript API
Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Word | For business | Windows
0 comments No comments
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.