Trying to end a OneNote Notebook using Powershell, to later open it under a new path, I get the below exception :
Ausnahme beim Aufrufen von "CloseNotebook" mit 1 Argument(en): "Der
Remoteprozeduraufruf ist fehlgeschlagen. (Ausnahme von HRESULT: 0x800706BE)"
In Zeile:1 Zeichen:1
+ $OneNote.CloseNotebook("{434555E5-54FC-4B61-98FB-158DFBB34B9F}{1}{B0} ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : COMException
Which roughly translates to:
Exception calling "CloseNotebook" with 1 Argument(s): "The remote procedure call failed". (Exception HRESULT: 0x800706BE)
This is the script I used to accomplish the task:
$OneNote = New-Object -ComObject OneNote.Application
[xml]$Hierarchy = ""
$OneNote.GetHierarchy("",[Microsoft.Office.InterOp.OneNote.HierarchyScope]::hspages,[ref]$Hierarchy)
$ID = ($Hierarchy.Notebooks.Notebook |Where-Object {$_.path -like "C:\temp\Test"}).ID
$ID
{434555E5-54FC-4B61-98FB-158DFBB34B9F}{1}{B0}
$OneNote.CloseNotebook($ID)
User contributions licensed under CC BY-SA 3.0