Office365 在使用word加载项时,如何使用office js API或任何其他方式以文件名保存word文档?
我阅读了本文档并遵循了这里提到的示例,但无法使用文件名保存文档。 例如Office365 在使用word加载项时,如何使用office js API或任何其他方式以文件名保存word文档?,office365,office-js,office-addins,Office365,Office Js,Office Addins,我阅读了本文档并遵循了这里提到的示例,但无法使用文件名保存文档。 例如 任何指针都会有很大帮助。这是预期的行为。目前还没有“另存为”功能,只有“保存”,因此它遵循Word的默认文件命名规则。如果以前从未保存过该文件,则第一行文本将用作文件名。作为解决方案,考虑以编程方式将期望的文件名添加为第一行文本,保存文件,然后删除第一行。是用错误名称保存的文档,还是根本没有保存?它保存在磁盘上,但以第一行作为文件名。没有SaveAs何时可用的路线图。 // Run a batch operation aga
任何指针都会有很大帮助。这是预期的行为。目前还没有“另存为”功能,只有“保存”,因此它遵循Word的默认文件命名规则。如果以前从未保存过该文件,则第一行文本将用作文件名。作为解决方案,考虑以编程方式将期望的文件名添加为第一行文本,保存文件,然后删除第一行。是用错误名称保存的文档,还是根本没有保存?它保存在磁盘上,但以第一行作为文件名。没有SaveAs何时可用的路线图。
// Run a batch operation against the Word object model.
Word.run(function (context) {
// Create a proxy object for the document.
var thisDocument = context.document;
// Queue a command to load the document save state (on the saved property).
context.load(thisDocument, 'saved');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
return context.sync().then(function () {
if (thisDocument.saved === false) {
// Queue a command to save this document.
thisDocument.save();
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
return context.sync().then(function () {
console.log('Saved the document');
});
} else {
console.log('The document has not changed since the last save.');
}
});
})
.catch(function (error) {
console.log("Error: " + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});