2016-08-03 65 views
1
$SearchString = "Table Text" 
$regex = [Regex]::Match($PgContent.Text, $SearchString) 
if($regex.Success) 
{ 
    $finalName = $fileDoc.Name 
    $Selection = $word.Selection 
    $finalDoc.ActiveWindow.ActivePane.View.SeekView = 1 
    $path = $outputPath + "TableText_" + $i + "_" + $finalName 
    $finalDoc.saveas([ref]$path) 
    $finalDoc.close() 
} 
else 
{ 
    'ignores the content 
} 

这部分代码是将文档拆分为单独页面后查找搜索字符串的位置。如果找到搜索字符串,则保存该页面,否则将其删除。该代码适用于不在Word文档中的表格中显示的文本。我是否需要在PowerShell中做一些特殊的事情才能使其搜索表格文本?在word文档表中搜索

+0

嗨,有没有什么办法让你分享一个示例文档来测试你的脚本(并尝试帮助)? – sodawillow

+0

我可以确定一个虚拟文件。我如何上传到这里?但你是对的,这与表格有关。我在文档的末尾添加了几个虚拟普通表,并对其进行搜索。但是表格当前的格式会跳过。 – Nolemonkey

+0

恐怕您必须为此使用第三方文件共享服务。 – sodawillow

回答

0

橡皮鸭终于找到了故障:搜索词实际上是不正确的(根据OP的评论)。