Diese Seite hat den Status einer Materialsammlung inklusiver einiger Skripte, um auf OnenNote zuzugreifen.
Das Material ist nicht ausgearbeitet und kann mehr als üblich Fehler enthalten!
Vieleicht findet ihr trotzdem eine hilfreiche Information hier
MSDN: Creating OneNote 2010 Extensions with the OneNote Object Model
MSDN: Enumerations (OneNote 2010 Developer Reference)
Beispiel 1: Anzeigen der geladenen OneNote-Notizbücher
Set-StrictMode -Version "2.0" Clear-Host [void][reflection.assembly]::LoadWithPartialName("Microsoft.Office.Interop.Onenote") $OneNote = New-Object Microsoft.Office.Interop.Onenote.ApplicationClass [Xml]$Xml = $Null $OneNote.GetHierarchy($Null, [Microsoft.Office.InterOp.OneNote.HierarchyScope]::hsNotebooks, [ref] $Xml) ($Xml.Notebooks.Notebook) | ft Name,Path,LastModifiedTime -AutoSize |
#mögliche Ausgabe name path lastModifiedTime ---- ---- ---------------- KaiIT N:\Kai\OneNote\KaiIT 2014-01-30T16:53:51.000Z myNotebook2 https://d.docs.live.net/4c7b6bf3d5e63/Dok/myNotebook2/ 2014-03-08T14:24:47.000Z |
Auf meinem Rechner sind also "KaiIT" und "myNotebook2" geladen.
Beispiel 2: Referenz auf ein bestimmtes Notizbuch setzen und Sektionen auslesen
Set-StrictMode -Version "2.0" Clear-Host $Notizbuchname = "KaiIT" [void][reflection.assembly]::LoadWithPartialName("Microsoft.Office.Interop.Onenote") $OneNote = New-Object Microsoft.Office.Interop.Onenote.ApplicationClass [Xml]$Xml = $Null $Onenote.GetHierarchy($null, [Microsoft.Office.InterOp.OneNote.HierarchyScope]::hsPages, [ref] $xml) #Referenz auf ein bestimmtes Notizbuch setzen #$myNotebook = ($xml.Notebooks.Notebook)[0] $myNotebook = $xml.Notebooks.Notebook | where name -eq $Notizbuchname #Alternativ #$myNotebook = $xml.Notebooks.Notebook | where {$_.name -eq $Notizbuchname} #Alternativ Write-Host "Angaben ueber das Notizbuch" $myNotebook Write-Host "Sektionen" $myNotebook.Section | Format-Table name |
#mögliche Ausgabe Angaben ueber das Notizbuch name : KaiIT nickname : Kai-IT ID : {29AB9590-88FE-4161-9B67-A4163A9C7A0A}{1}{B0} path : N:\Kai\OneNote\KaiIT lastModifiedTime : 2014-01-30T16:53:51.000Z color : #FFD869 isUnread : true Section : {01-MB, 02-Joomla, 03-HTML, 04-CSS...} SectionGroup : SectionGroup Sektionen name ---- 01-MB 02-Joomla 03-HTML 04-CSS ... |
Beispiel 3: Auslesen einer OneNote-Seite
Set-StrictMode -Version "2.0" Clear-Host $NotebookName = "KaiIT" $Sectionname = "01-MB" $Pagename = "TestPage" [void][reflection.assembly]::LoadWithPartialName("Microsoft.Office.Interop.Onenote") $OneNote = New-Object Microsoft.Office.Interop.Onenote.ApplicationClass [Xml]$Xml = $Null $Onenote.GetHierarchy($Null, [Microsoft.Office.InterOp.OneNote.HierarchyScope]::hsPages, [ref] $Xml) $MyNotebook = $Xml.Notebooks.Notebook | where name -eq $NoteBookName $MySection = $MyNotebook.Section | where name -eq $SectionName $MyPage = $MySection.Page | where name -eq $Pagename [Xml]$Pagexml = $null $Onenote.GetPageContent($MyPage.ID, [ref] $PageXml) $PageXml.InnerXml |
#mögliche Ausgabe <?xml version="1.0"?><one:Page xmlns:one="http://schemas.microsoft.com/office/onenote/2013/onenote" ID="{91FDE01A-F3F4-4078- BAE0-17741498E9FC}{1}{E1946273634373173674041923866976897880739151}" name="TestPage" dateTime="2014-03-08T17:46:37.000Z" las tModifiedTime="2014-03-08T18:14:55.000Z" pageLevel="1" isCurrentlyViewed="true" lang="de"><one:QuickStyleDef index="0" name= "PageTitle" fontColor="automatic" highlightColor="automatic" font="Calibri Light" fontSize="20.0" spaceBefore="0.0" spaceAft er="0.0" /><one:QuickStyleDef index="1" name="p" fontColor="automatic" highlightColor="automatic" font="Calibri" fontSize="1 1.0" spaceBefore="0.0" spaceAfter="0.0" /><one:PageSettings RTL="false" color="automatic"><one:PageSize><one:Automatic /></o ne:PageSize><one:RuleLines visible="false" /></one:PageSettings><one:Title lang="de"><one:OE author="Kaiusr" authorInitials= "K" lastModifiedBy="Kaiusr" lastModifiedByInitials="K" creationTime="2014-03-08T18:11:19.000Z" lastModifiedTime="2014-03-08T 18:11:19.000Z" objectID="{0AAA5500-FBA1-4C16-96A4-956CA31E0C07}{15}{B0}" alignment="left" quickStyleIndex="0"><one:T><![CDAT A[TestPage]]></one:T></one:OE></one:Title><one:Outline author="Kaiusr" authorInitials="K" lastModifiedBy="Kaiusr" lastModifi edByInitials="K" lastModifiedTime="2014-03-08T18:14:54.000Z" objectID="{779B55C7-B3C1-4B51-91E8-B056EB1F7CF5}{22}{B0}"><one: Position x="54.0" y="122.400001525879" z="0" /><one:Size width="89.38968658447265" height="13.42771339416504" /><one:OEChild ren><one:OE creationTime="2014-03-08T18:14:54.000Z" lastModifiedTime="2014-03-08T18:14:54.000Z" objectID="{779B55C7-B3C1-4B5 1-91E8-B056EB1F7CF5}{23}{B0}" alignment="left" quickStyleIndex="1"><one:T><![CDATA[Lore Ipsum]]></one:T></one:OE></one:OEChi ldren></one:Outline></one:Page> PS C:\Windows\System32\WindowsPowerShell\v1.0> |
Diese XML-Ausgabe beschreibt eine klene Onepageseite eines meiner Notizbücher. Wenn man sich am Ende die Eigenschaften von pagemxl mit "pagexml | get-member" näher ansieht, findet man auch Methoden, die wahrscheinlich zum Import oder Verändern von Xml-Daten. (LoadXML / WriteContentTo / CloneNode ...) bereitstehen.