如何从onenote2016获取当前查看的笔记本。
Application.OnenoteApplication.GetHierarchy()带来了笔记本中列出的顶级书籍。
isCurrentlyViewed属性是" True"对于onenote笔记本列表中列出的所有笔记本。当一个:Page [@isCurrentlyViewed = \" true \"]"将变为虚假。
答案 0 :(得分:0)
使用" GetActiveNotebook" https://github.com/OfficeDev/office-js-docs/blob/master/reference/onenote/application.md#getactivenotebook
OneNote.run(function (context) {
// Get the active notebook.
var notebook = context.application.getActiveNotebook();
// Queue a command to load the notebook.
// For best performance, request specific properties.
notebook.load('id,name');
// Run the queued commands, and return a promise to indicate task completion.
return context.sync()
.then(function () {
// Show some properties.
console.log("Notebook name: " + notebook.name);
console.log("Notebook ID: " + notebook.id);
});
})
.catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
答案 1 :(得分:0)
尝试:Application.Windows.CurrentWindow.CurrentNotebookId 这将获得当前的笔记本ID。