我正在使用vb.net並嘗試從onenote中的筆記中提取文本(我將爲OneNote2010或2016解決)。以下代碼能夠複製標題書籍和章節的名稱......到文本框(用於測試),但不是註釋的實際內容。我知道這可能是非常簡單的,一旦你知道如何做一次。但我對我/谷歌搜索的生活無法弄清楚這個魔法命令。 (在Visual Basic中)。使用XmlDocument從OneNote中提取筆記內容類
感謝您的閱讀!
Imports Microsoft.Win32
Imports System.Security.Permissions
Imports Microsoft.Office.Interop
Imports System.Xml
Public Class Form1
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim strNamespace As String = "http://schemas.microsoft.com/office/onenote/2013/onenote"
Dim outputXML As String
Dim onApplication As OneNote.Application = New OneNote.Application
onApplication.GetHierarchy(Nothing, OneNote.HierarchyScope.hsSections, outputXML)
Dim xmlDoc As XmlDocument = New XmlDocument()
xmlDoc.LoadXml(outputXML)
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(xmlDoc.NameTable)
nsmgr.AddNamespace("one", strNamespace)
Dim Testa As XmlNode = xmlDoc.SelectSingleNode("//one:Section[@name='TestNote']", nsmgr)
TextBox1.Text = outputXML
End Sub
End Class
Jayongg嗨, 當我嘗試了GetPageContent路線,我收到了「getpagecontent」不是「的OneNote」的成員。也許這是我的問題的路線? 感謝您的所有幫助! – user2261192
奇怪。您是否使用此API:https://msdn.microsoft.com/en-us/library/office/gg649853(v=office.14).aspx – jayongg
我有: 「Imports Microsoft.Win32 Imports System.Security。權限 進口Microsoft.Office.Interop 進口System.Xml「 在頂部...對不起,我還是這個新的。 謝謝 – user2261192