简体   繁体   中英

Word addin, set filename

If one starts a blank file on Word you can usually see in the top bar a name such as "Document1", "Document2" and so on.

Yet, if you attempt to open a file using the Word JS API like this:

Word.run((context) => {
  context.application.createDocument(documentB64).open()
  return context.sync()
})

The top bar comes out like this:

在此处输入图像描述

No filename is set.

To set a filename/handle(?), I tried using the code given here Office JS - Add customProperty to new document but that didn't help.

My addin is usually used in conjunction with another (VSTO) add-on and that add-on can't work properly with the documents opened by my addin and I believe the lack of a filename (/handle?) explains it to some extent.

Is there something I can do about this?

Thank you

Currently you can't do this because the newly created document is just a temporary file and not saved. can you try to call the following code to make sure the newly created file is saved?

const documentCreated = context.application.createDocument(externalDoc);
 documentCreated.save();
 documentCreated.open();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM