OneNote JS API - 如何通过标题将页面添加到特定部分
OneNote JS API - How to add a page to a specific section by title
我想添加一个页面到特定的部分,但是文档只给出了如何调用当前页面的例子即
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));
}
});
我想添加一个页面到特定的部分,但是文档只给出了如何调用当前页面的例子即
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));
}
});