powershell - Microsoft Word power shell 脚本跳过所有已删除的修订行/段落
问题描述
我正在尝试阅读 word 文档并从特定段落或句子中获取数字。但是有些句子被删除了,并且正在修订轨道上。所以我的输出仍然包含带有预期数字的已删除句子。基本上我不想在输出中包含已删除的句子。我也无法通过接受所有修订来保存文件。
我的代码如下所示。
$file2 = "C:\work\Powershell\Scenarios\ALPtest Life AnnualV12.docx"
$word = New-Object -ComObject Word.Application
$document = $word.documents.open($file2,$false,$true)
if ($document.Content.Find.Execute('Document Conditions'))
{
Write-Host $WantFile "contains 'Document Conditions'" `n
$Paras = $Document.Paragraphs
foreach($para in $paras)
{
$Text= $para.Range.Text
if ($text.Trim() -eq 'Document Conditions')
{
Write-Host "Hurahhhhhhh"
$start=1
}
elseif ( $start -eq 1 -and ($text -match "[0-9]"))
{
if ($text.Revsision -ne "wdRevisionDelete")
{
Write-Host "Found revision del : $text"
}
}
}
}
非常感谢您帮助对此进行排序。
解决方案
推荐阅读
- reactjs - 来自 NextJs 的外部 API 发布请求
- php - 如何配置 XAMPP 以使用 PHP 调试器
- excel - Power Query 公式语言 - 根据父相邻列值获取子级
- javascript - javascript 中 __proto__ 和 [[ Prototype ]] 的区别
- javascript - 如何编辑用户输入给出的 javascript 变量?
- virtual-machine - 依赖光标位置的代码在虚拟机中是否仍然有效
- git - 任何人都可以建议使用 Git VCS 维护 Netsuite SDF 的工作流程吗?
- c++ - ebpf 初学者问题:bpf_trace_printk 导致错误?
- c++ - 某种方式来判断文件是否是带有 ssh_scp_request_get_permissions 或其他函数 libssh 的符号链接
- sql-server - 尝试按字母数字值排序时传递给 LEFT 或 SUBSTRING 函数的长度参数无效