2017-03-08 55 views
0

如何从onenote2016获取当前查看的笔记本。当前浏览的笔记本onenote

Application.OnenoteApplication.GetHierarchy()将笔记本中列出的顶级书籍带入其中。

对于onenote中Notebook列表中列出的所有笔记本,isCurrentlyViewed属性为“True”。当之一:[@isCurrentlyViewed = \ “真正\”]”将变为假

回答

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)); 
    } 
}); 
+0

我需要修复c#。 – Geeth

0

尝试:Application.Windows.CurrentWindow.CurrentNotebookId ,将得到你当前的笔记本ID。

+0

Application.Windows.CurrentWindow带来空值。 – Geeth