首页 > 解决方案 > 从 Onenote 页面检索和更新 NoteTag

问题描述

我为 Onenote 创建了一个 Office 加载项,我正在尝试检索和更新页面上的 NoteTags 属性。

该图显示了带有 4 个 ToDo 标签的 Onenote 页面。它还显示了由以下代码生成的控制台日志。在控制台中,我可以看到来自 ToDo 标签的段落 ID、类型和文本。

我需要在代码中更改哪些内容以检索 NoteTag 的“Id”、“Status”和“Type”,以及如何清除已检查的 ToDo 标签?

Onenote 页面

function getParagraph() {
    OneNote.run(function (context) {

        // Get the collection of pageContent items from the page.
        var pageContents = context.application.getActivePage().contents;
    
        // Get the first PageContent on the page, and then get its Outline's first paragraph.
        var pageContent = pageContents.getItemAt(0);
        var paragraphs = pageContent.outline.paragraphs;

        paragraphs.load("id, type, richText");
    
        // Run the queued commands, and return a promise to indicate task completion.
        return context.sync()
            .then(function () {
                // Display the properties.
                $.each(paragraphs.items, function(index, paragraph) {
                    // Write text from paragraph to console
                    console.log(
                        "Paragraph Id: " + paragraph.id +
                        "; Type: " + paragraph.type + 
                        "; Text: " + paragraph.richText.text);
                });
            });
    })
    .catch(function(error) {
        onError(error);
    });   
}

标签: office-addinsonenote-api

解决方案


推荐阅读