我必须写一个powershell脚本,可以分析word文档。具体地说,它必须从文本框中读取文本并将其存储在变量中。我知道如何阅读文本,例如从段落中阅读,但我不知道如何处理文本框。如能提供样品,我将不胜感激。
下面是我的代码的一部分:
$Word = New-Object -comobject Word.Application
$Word.Visible = $False
$datasheet = $word.Documents.Open($files[$i].FullName)
$value = ....?这是我需要阅读的框的屏幕截图:

发布于 2020-08-17 23:15:50
枚举Shapes集合的内容并筛选msoTextBox type (17)的形状:
$datasheet.Shapes |Where-Object {$_.Type -eq 17} |ForEach-Object {
# copy $_.TextFrame.TextRange.Text to wherever you need it in here
# $_.TextFrame.TextRange is a range object like any other (useful if you need formatting details or raw XML for example)
}https://stackoverflow.com/questions/63453213
复制相似问题