Powershell脚本不起作用(拼写项目)
$app = New - Object - ComObject 'Word.Application'
$app.visible = $true
$doc = $app.Documents.Add(
}
$doc.Content.text = 'Here's an exmple of mispeled txt."
$selection = $app.Selection
$report = @(
}
foreach($word in ($doc.Words | Select - ExpandProperty Text)) {
if (!($app.CheckSpelling($word))) {
$result = New - Object - TypeName psobject - Property @(Mispelled = $word)
$sug = $app.GetSpellingSuggestions($word) | Select - ExpandProperty name
if ($sug) {
$report += New - Object psobject - Property @ {
Misspelled = $word;
Suggestions = $sug
}
} else {
$report += New - Object - TypeName psobject - Property @ {
Misspelled $word; =
Suggestions "No Suggestion"
}
}
}
}
$Sreport | Select - Property Misspelled, Suggestions
你好。我在网上找到了这个脚本,我试图通过PowerShell使用MS Word的拼写校正来输出拼写错误的英语单词列表以及他们的拼写建议。我没有编码知识,所以我不知道为什么脚本不起作用。有人可以帮我吗?谢谢!
$app = New - Object - ComObject 'Word.Application'
$app.visible = $true
$doc = $app.Documents.Add(
}
$doc.Content.text = 'Here's an exmple of mispeled txt."
$selection = $app.Selection
$report = @(
}
foreach($word in ($doc.Words | Select - ExpandProperty Text)) {
if (!($app.CheckSpelling($word))) {
$result = New - Object - TypeName psobject - Property @(Mispelled = $word)
$sug = $app.GetSpellingSuggestions($word) | Select - ExpandProperty name
if ($sug) {
$report += New - Object psobject - Property @ {
Misspelled = $word;
Suggestions = $sug
}
} else {
$report += New - Object - TypeName psobject - Property @ {
Misspelled $word; =
Suggestions "No Suggestion"
}
}
}
}
$Sreport | Select - Property Misspelled, Suggestions
Hello. I found this script online, from which I'm trying to output a list of misspelled English words together with their spelling recommendations, using MS Word's spelling corrections via Powershell. I don't have coding knowledge, so I don't know why isn't the script working. Could someone help me out? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这有效!您没有提及想要的输出,所以希望这没关系。
您在正确的道路上,但有一些语法和括号问题
This works, i think! You didnt mention the output you wanted so hope this is ok.
You were on the right track but had some syntax and bracket issues