Addin word : Load header and footer from base64 file

CorGri 11 Reputation points
2021-04-15T16:12:54.183+00:00

Hi,

I have a .docx encoded in base64 and I try to put this document in a blank Word with my Word Adding tool.
(WordApi 1.3 / Angular 7)

I already tried to use
context.document.body.insertFileFromBase64(this.myFileBase64, Word.InsertLocation.replace);
But it doesn't include my header nor footer (of course, it's only loading the body).

Then I tried to get this header from another document using
context.document.sections.getFirst().getHeader("Primary");
but it doesn't work neither

The only way I find was to load my base64 file in a new Word instance, but it's closing my addin and erasing my settings

      let docWord:Word.DocumentCreated;
      docWord = app.createDocument(this.myFileBase64);
      docWord.open();

Can I load the entire Word file (header body footer) in a Word document?
Is there a way to load/reload my base64 file into a Word instance?

Thanks.

Microsoft 365 and Office | Development | Other
{count} votes

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.