OneNote JS API-如何按标题将页面添加到特定分区



我想在特定部分添加一个页面,但文档只给出了如何调用当前页面(即(的示例

context.application.getActiveSection((.addPage;

但我一辈子都不知道该如何按标题选择特定的页面。任何帮助都相当于

您可以获取活动笔记本,然后获取活动笔记本中的分区,然后查找具有您要查找的名称的分区。

https://dev.office.com/reference/add-ins/onenote/notebook

OneNote.run(function (context) {
// Gets the active notebook.
var notebook = context.application.getActiveNotebook();
// Queue a command to get immediate child sections of the notebook. 
var childSections = notebook.sections;
// Queue a command to load the childSections. 
context.load(childSections);
// Run the queued commands, and return a promise to indicate task completion.
return context.sync()
.then(function() {
$.each(childSections.items, function(index, childSection) {
console.log("Immediate child section name: " + childSection.name);
});            
});
})
.catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});

最新更新