powershell - OneNote.Application.CloseNotebook 上的远程过程调用失败
问题描述
尝试使用 Powershell 结束 OneNote Notebook,稍后在新路径下打开它,我得到以下异常:
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
大致翻译为:
Exception calling "CloseNotebook" with 1 Argument(s): "The remote procedure call failed". (Exception HRESULT: 0x800706BE)
这是我用来完成任务的脚本:
$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)
解决方案
推荐阅读
- cors - 从 Elm 中的 HTTP 响应中读取自定义标头
- scala - 遍历 Array[DateType] 类型的 Spark 列,查看数组中是否有连续两天
- r - 确保最后一行是从数据集中删除的唯一行的最佳方法是什么
- python-3.x - 如何修改此线性时间算法?我正在对 pandas DataFrame 进行基于窗口的规范化
- android - 引起:java.lang.IllegalStateException:TextView 不能为空
- docker - Azure devops 发布管道 - 环境之间共享的特定 docker 映像
- c++ - c ++程序在字符数组中插入单词
- javascript - 如何使用 AsciiMath 显示 MathJax?
- java - Facebook 广告上的“无填充”
- python - Python在随机函数中打印行号