More details coming shortly, but here's the "gist" of it...
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web")
$on = New-Object -ComObject OneNote.Application
$ns = [system.xml.linq.xnamespace]"http://schemas.microsoft.com/office/onenote/2010/onenote"
clear
$pageId = $on.Windows.CurrentWindow.CurrentPageId
$on.GetPageContent($pageId, [ref]$xml)
$xd = [system.xml.linq.xdocument]::Parse($xml)
# extract url from sections 'pasted from' a web page
$url1 = $xd.Descendants($ns + "T") | where { $_.Value -like "Pasted from*" } | foreach {
[system.web.httputility]::htmldecode(($_.Value -replace "<(.|\n)*?>")).Replace("Pasted from <","").Replace(">","")
}
$url1
# extract rows from a onenote table
foreach($row in $xd.Descendants($ns + "Row"))
{
$arr1 = @($row.Descendants($ns + "Cell") | foreach { (
[system.web.httputility]::htmldecode($_.LastNode.Value -replace "<(.|\n)*?>"))
})
$arr1
}
Thank you @ShayLevy for the tweak!
@solevangelist Looks like you can use its ComObject as any other office app: New-Object -ComObject OneNote.Application
— ShayLevy (@ShayLevy) June 7, 2012