{"id":33207,"date":"2010-12-21T18:47:39","date_gmt":"2010-12-21T17:47:39","guid":{"rendered":"https:\/\/www.fuhaijun.com\/?p=33207"},"modified":"2024-11-06T11:21:15","modified_gmt":"2024-11-06T03:21:15","slug":"powershell2-0%e4%b9%8b%e4%b8%8ecom%e5%af%b9%e8%b1%a1%e4%ba%a4%e4%ba%92%e4%ba%8cword%e8%87%aa%e5%8a%a8%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.fuhaijun.com\/?p=33207","title":{"rendered":"PowerShell2.0\u4e4b\u4e0eCOM\u5bf9\u8c61\u4ea4\u4e92(\u4e8c)Word\u81ea\u52a8\u5316"},"content":{"rendered":"<p>\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e3b\u8981\u63cf\u8ff0\u4e86COM\u6a21\u578b\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u4ee5\u53ca\u5728powershell\u4e2d\u5982\u4f55\u8c03\u7528COM\uff0c\u672c\u7bc7\u6587\u7ae0\u4e2d\u5c06\u4f1a\u7740\u91cd\u4ecb\u7ecdpowershell\u4e2d\u901a\u8fc7COM\u64cd\u4f5cWord\u8fbe\u5230\u81ea\u52a8\u5316\u7ba1\u7406\u7684\u76ee\u7684\u3002<\/p>\n<p>COM\u4e3b\u8981\u7528\u4e8e\u4e0e\u5176\u4ed6\u7a0b\u5e8f\u7684\u81ea\u52a8\u5316\uff0c\u662f\u9ad8\u7ea7\u7528\u6237\u3001\u7ba1\u7406\u5458\uff0c\u4ee5\u53ca\u5f00\u53d1\u4eba\u5458\u7684\u4e0d\u4e8c\u9009\u62e9\u3002\u8f6f\u4ef6\u4ea7\u54c1\u901a\u5e38\u4f1a\u4ee5COM\u5bf9\u8c61\u7684\u5f62\u5f0f\u5411\u5916\u63d0\u4f9b\u5e94\u7528\u670d\u52a1\uff0c\u8fd9\u6837\u5373\u53ef\u4ece\u5176\u4ed6\u8bed\u8a00\u4e2d\u8c03\u7528\u8be5\u9879\u529f\u80fd\u3002\u4f5c\u4e3aCOM\u5bf9\u8c61\u6700\u4f73\u7684\u5b9e\u4f8b\u83ab\u8fc7\u4e8eMicrosoft Office\u5de5\u5177\uff0c\u5728\u8fd9\u4e2a\u5de5\u5177\u96c6\u4e2d\u7684\u6240\u6709\u7a0b\u5e8f\u90fd\u4ee5COM\u5bf9\u8c61\u7684\u5f62\u5f0f\u5411\u5916\u63d0\u4f9b\u7a0b\u5e8f\u5bf9\u8c61\u3001\u6587\u6863\uff0c\u4ee5\u53ca\u5176\u4ed6\u670d\u52a1\uff0c\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u5bf9\u8c61\u521b\u5efa\u548c\u64cd\u4f5c\u6587\u6863\u548c\u5404\u7c7b\u6570\u636e\u5bf9\u8c61\u3002<\/p>\n<p>Word\u901a\u8fc7word.Application\u552f\u4e00\u5730\u6807\u8bc6ProgID\uff0cWord\u5e94\u7528\u901a\u8fc7\u81ea\u52a8\u5316\u754c\u9762\u5411\u5916\u63d0\u4f9b\u6587\u6863\u548c\u6587\u5b57\u7684\u6838\u5fc3\u64cd\u4f5c\u3002\u53ef\u4ee5\u6253\u5f00\u4e00\u4e2a\u6587\u6863\uff0c\u8bfb\u53d6\u548c\u4fee\u6539\u5176\u4e2d\u7684\u6587\u5b57\uff0c\u5e76\u4fdd\u5b58\u66f4\u6539\u3002\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u64cd\u4f5c\u7684\u662fRange\u5bf9\u8c61\uff0c\u719f\u6089Word\u7684VBA\uff08Visual Basic For Application\uff09\u7f16\u7a0b\u7684\u7528\u6237\u53ef\u80fd\u4f1a\u5bf9\u5b83\u6bd4\u8f83\u719f\u6089\uff0c\u8fd9\u79cd\u5bf9\u8c61\u9488\u5bf9\u7684\u662f\u53ef\u5355\u72ec\u5904\u7406\u6587\u5b57\u5355\u5143\u3002\u7528\u6237\u53ef\u4ee5\u6dfb\u52a0\u5220\u9664\u6587\u5b57\u3001\u8bbe\u7f6e\u4e0d\u540c\u7684\u5b57\u4f53\uff0c\u5207\u6362\u6587\u5b57\u6216\u80cc\u666f\u7684\u989c\u8272\u3001\u4eceDocument\u5bf9\u8c61\u63d0\u4f9b\u7684\u5c5e\u6027\u521b\u5efa\u6216\u83b7\u53d6\u6587\u5b57\u533a\u57df\u5bf9\u8c61\uff0c\u5e76\u4ece\u5f53\u524d\u9009\u53d6\u7684\u6587\u5b57\u4e2d\u83b7\u53d6\u5185\u5bb9\u3002\u65e0\u8bba\u662f\u4ee5\u4f55\u79cd\u65b9\u5f0f\u83b7\u53d6\u7684\u6587\u5b57\u533a\u57df\u5bf9\u8c61\uff08range\uff09\uff0c\u5747\u53ef\u4ee5\u76f8\u540c\u7684\u65b9\u6cd5\u6765\u5904\u7406\u3002<\/p>\n<p>\u672c\u6587\u5c06\u9488\u5bf9Micosoft Word 2003\u4e3a\u6a21\u677f\u6765\u4ecb\u7ecd\uff0c\u800cWord 2007\u652f\u6301\u8bb2\u8ff0\u7684\u5185\u5bb9\u3002\u5fae\u8f6f\u7684\u7a0b\u5e8f\u5411\u6765\u4ee5\u5411\u540e\u7ee7\u627f\u516c\u7528\u5bf9\u8c61\u8457\u79f0\uff0c\u5728Word 2003\u548cWord 2007\u63d0\u4f9b\u7684\u53d8\u91cf\u65b9\u6cd5\u548c\u5c5e\u6027\u57fa\u672c\u76f8\u540c\uff0c\u4ee3\u7801\u53ef\u4ee5\u5728\u4e0d\u505a\u6216\u7565\u52a0\u4fee\u6539\u7684\u60c5\u51b5\u4e0b\u76f4\u63a5\u7528\u4e8eWord 2007\u4e0a\u3002<\/p>\n<p align=\"left\"><a name=\"OLE_LINK5\"><\/a><a name=\"OLE_LINK4\"><strong>\uff081<\/strong><\/a><strong>\uff09\u6253\u5f00\u6587\u6863\u5e76\u63d0\u53d6\u5185\u5bb9<\/strong><\/p>\n<p>\u9996\u5148\u4ece\u7b80\u5355\u7684word\u76f8\u5173\u7684\u64cd\u4f5c\u5f00\u59cb\uff0c\u5373\u4ece\u6587\u6863\u4e2d\u8bfb\u53d6\u6587\u5b57\u3002\u5728\u5178\u578b\u7684\u4f01\u4e1a\u73af\u5883\u4e0b\u5f88\u591a\u65f6\u5019\u9700\u8981\u751f\u6210\u6587\u6863\u9012\u4ea4\u7ed9\u5176\u4ed6\u7528\u6237\u5ba1\u6279\uff0c\u5e76\u6700\u7ec8\u4fdd\u5b58\u5728\u5b58\u50a8\u8282\u70b9\u4e2d\u3002\u6240\u4ee5\u4ece\u6587\u6863\u4e2d\u63d0\u53d6\u5185\u5bb9\u662f\u4e2a\u5f88\u91cd\u8981\u7684\u529f\u80fd\uff0c\u5982\u679c\u80fd\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\uff0c\u5219\u53ef\u521b\u5efa\u811a\u672c\u7528\u4e8e\u641c\u7d22\u5173\u952e\u5b57\u3001\u4ece\u6587\u6863\u4e2d\u63d0\u53d6\u76f8\u5173\u4fe1\u606f\uff0c\u521b\u5efa\u62a5\u544a\u5e76\u5408\u5e76\u6587\u6863\u7b49\u5f88\u591a\u573a\u5408\u3002<\/p>\n<p>\u6587\u4ef6\u540d\u4e3a\u201cSample.doc\u201d\u7684Word\u6587\u6863\u4e2d\u5305\u542b\u4e24\u884c\u5185\u5bb9\uff0c\u5982\u56fe1\u6240\u793a\u3002<\/p>\n<p>\u4e3a\u4e86\u901a\u8fc7Shell\u8bfb\u53d6\u51fa\u6587\u6863\u7684\u5185\u5bb9\uff0c\u9700\u8981\u83b7\u53d6\u4e00\u4e2aWord.Application\u5bf9\u8c61\u7684\u5b9e\u4f8b\uff0c\u5b83\u5141\u8bb8\u6253\u5f00\u6587\u6863\uff0c\u5e76\u83b7\u53d6\u8be5\u6587\u6863\u5bf9\u8c61\u7684\u5f15\u7528\u3002\u83b7\u53d6\u540e\u5373\u53ef\u901a\u8fc7Document\u7684Content\u5c5e\u6027\u6765\u83b7\u53d6\u5b8c\u6574\u7684\u5185\u5bb9\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2aRange\u5bf9\u8c61\uff0c\u8fd9\u4e2a\u5bf9\u8c61\u53ef\u4ee5\u88ab\u7528\u4e8e\u63d0\u53d6\u5185\u5bb9\u3002\u628a\u8fd9\u4e2a\u811a\u672c\u4fdd\u5b58\u4e3aGet-DocumentText.ps1\uff0c\u5176\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>$wordApp = New-Object -COM Word.Application<\/p>\n<p>$file = (dir Sample.doc).FullName<\/p>\n<p>$doc = $wordApp.Documents.Open($file)<\/p>\n<p>$text = $doc.Content.Text<\/p>\n<p>$text<\/p>\n<p>$wordApp.Exit<\/p>\n<p align=\"center\"><a href=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image3.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px\" height=\"363\" alt=\"image\" src=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image_thumb2.png\" width=\"644\" border=\"0\" \/><\/a> <\/p>\n<p align=\"center\">\u56fe1 \u7528word Sample.doc\u6587\u6863\u4e2d\u5305\u542b\u4e24\u884c\u5185\u5bb9<\/p>\n<p>\u6267\u884c\u8fd9\u4e2a\u811a\u672c\uff0c\u7ed3\u679c\u5982\u56fe2\u6240\u793a\uff0c\u53ef\u4ee5\u770b\u5230\u5df2\u7ecf\u83b7\u53d6Range\u5bf9\u8c61\u7684Text\u5c5e\u6027\uff1b\u53e6\u5916\u9700\u8981\u5f3a\u8c03\u7684\u4e00\u70b9\u662f\uff0c\u9700\u8981\u4f20\u9012\u8981\u8bfb\u53d6\u6587\u4ef6\u7684\u7edd\u5bf9\u5730\u5740\u3002<\/p>\n<p align=\"center\"><a href=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image4.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px\" height=\"442\" alt=\"image\" src=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image_thumb3.png\" width=\"673\" border=\"0\" \/><\/a> <\/p>\n<p align=\"center\">\u56fe2 \u901a\u8fc7Word.Application\u8bfb\u53d6\u7684Word\u6587\u6863<\/p>\n<p>\u3010\u6ce8\u610f\u3011<\/p>\n<p>Documents\u96c6\u5408\u7684Open\u65b9\u6cd5\u9700\u8981\u4e00\u4e2a\u5b8c\u6574\u8def\u5f84\uff0c\u76f8\u5bf9\u8def\u5f84\u65e0\u6548\uff0c\u56e0\u4e3aWord\u5728\u8fd0\u884c\u65f6\u7684\u8def\u5f84\u53ef\u4ee5\u4e0d\u540c\u4e8e\u5f53\u524d\u8def\u5f84\u3002\u5982\u5f88\u591a\u60c5\u51b5\u4e0b\u542f\u52a8\u7684Shell\u7684\u5f53\u524d\u76ee\u5f55\u6709\u53ef\u80fd\u662fC:\\Windows\\System32\uff0c\u800c\u6240\u6709\u6587\u6863\u4fdd\u5b58\u5728\u53e6\u5916\u7684\u76ee\u5f55\u4e2d\u3002<\/p>\n<p>\u3010\u5f3a\u8c03\u3011<\/p>\n<p>Get-DocumentText.ps1\u811a\u672c\u5728\u4f7f\u7528COM\u4e4b\u540e,\u5fc5\u987b\u9500\u6bc1\u5148\u524d\u521b\u5efa\u7684COM\u5b9e\u4f8b\uff1b\u5426\u5219\u5c06\u4f1a\u6302\u8d77Winword.exe\u8fdb\u7a0b\u3002\u5c3d\u7ba1\u4e0d\u4f1a\u6709\u592a\u660e\u663e\u7684\u95ee\u9898\uff0c\u4f46\u662f\u4f1a\u5360\u7528\u7269\u7406\u5185\u5b58\u3002\u751a\u81f3\u5728\u6ca1\u6709\u6210\u529f\u9000\u51fa\u5bf9\u8c61\u7684\u60c5\u51b5\u4e0b\u4fdd\u7559\u4e00\u4e2a\u6307\u5411\u6253\u5f00\u6587\u6863\u7684\u5f15\u7528\u5e76\u9501\u5b9a\u6587\u6863\uff0c\u8fd9\u6837\u5176\u4ed6\u7528\u6237\u5c06\u65e0\u6cd5\u6b63\u5e38\u8bbf\u95ee\u8fd9\u4e2a\u6587\u4ef6\u3002<\/p>\n<p>\u80fd\u591f\u770b\u5230\u6240\u6709\u7684\u6587\u5b57\u662f\u6324\u5728\u540c\u4e00\u884c\u4e2d\uff0c\u8fd9\u662f\u7531\u4e8e\u5c06\u5bcc\u683c\u5f0f\u6587\u672c\u8f6c\u6362\u4e3a\u65e0\u683c\u5f0f\u5b57\u7b26\u4e32\u5e26\u6765\u7684\u526f\u4f5c\u7528\u3002\u5982\u679c\u9700\u8981\u663e\u793a\u6bb5\u843d\u7ed3\u6784\uff0c\u5219\u9700\u8981\u4f7f\u7528DocumentPargraphs\u96c6\u5408\u3002\u5b83\u4f1a\u8fd4\u56de\u4e00\u7cfb\u5217Paragraph\u5bf9\u8c61\uff0c\u6bcf\u4e2a\u5bf9\u8c61\u5728\u6587\u6863\u4e2d\u90fd\u4ee5\u4e00\u4e2a\u6bb5\u843d\u7684\u5f62\u5f0f\u5b58\u5728\u3002\u8fd9\u4e9b\u5bf9\u8c61\u4e2d\u7684\u6bcf\u4e00\u4e2a\u90fd\u5305\u542b\u6587\u5b57\u533a\u57df\u5bf9\u8c61\uff08range\uff09\uff0c\u53ef\u4ee5\u7528\u5176\u83b7\u53d6\u771f\u5b9e\u7684\u6587\u672c\u5185\u5bb9\u3002\u4e3a\u4e86\u80fd\u591f\u4eceWord\u6587\u6863\u4e2d\u8bfb\u53d6\u51fa\u539f\u59cb\u7684\u6bb5\u843d\u7ed3\u6784\u548c\u5185\u5bb9\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cGet-DocumentParagraph.ps1\u201d\u7684\u811a\u672c\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>$wordApp = New-Object -COM Word.Application<\/p>\n<p>$file = (dir Sample.doc).FullName<\/p>\n<p>$doc = $wordApp.Documents.Open($file)<\/p>\n<p>$paragraphs = $doc.Paragraphs<\/p>\n<p>foreach ($paragraph in $Paragraphs)<\/p>\n<p>{<\/p>\n<p>Write-Host &quot;PARAGRAPH:&quot;<\/p>\n<p>Write-Host $paragraph.Range.Text<\/p>\n<p>}<\/p>\n<p>$wordApp.Quit()<\/p>\n<p>\u6267\u884c\u7ed3\u679c\u5982\u56fe3\u6240\u793a\uff0c\u524d\u8ff0\u4ee3\u7801\u4e2d\u7528foreach\u8bed\u53e5\u901a\u8fc7\u7d22\u5f15\u8bbf\u95ee\u6bcf\u4e2a\u6587\u5b57\u533a\u57df\u7684\u5185\u5bb9\u5e76\u6253\u5370\u3002\u53ef\u4ee5\u770b\u5230\u5171\u67093\u4e2a\u6bb5\u843d\uff0c\u5176\u4e2d\u4e2d\u95f4\u4e00\u4e2a\u53ea\u5305\u542b\u56de\u8f66\uff0c\u65e0\u6cd5\u5728\u5c4f\u5e55\u4e0a\u6253\u5370\u800c\u53ea\u8f93\u51fa\u4e86paragraph:\u5b57\u6837\u3002\u53ef\u4ee5\u731c\u60f3\u8fd9\u91cc\u6bb5\u843d\u7684\u5206\u5272\u901a\u8fc7\u56de\u8f66\u6765\u533a\u5206\uff0c\u7531\u4e8e\u7a7a\u884c\u4e2d\u5b58\u5728\u56de\u8f66\uff0c\u6240\u4ee5\u8f93\u51fa\u65f6\u5c3d\u7ba1\u6ca1\u6709\u6587\u5b57\uff0c\u8fd8\u662f\u6709\u6bb5\u843d\u5b58\u5728\uff0c\u56e0\u800c\u51fa\u73b0\u4e86\u7a7a\u884c\u3002<\/p>\n<p align=\"center\"><a href=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image5.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px\" height=\"442\" alt=\"image\" src=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image_thumb4.png\" width=\"673\" border=\"0\" \/><\/a> \u56fe3 \u6267\u884c\u7ed3\u679c<\/p>\n<p><a name=\"OLE_LINK3\">\u5f53\u7136\u6211\u4eec\u4e5f\u53ef\u4ee5\u5b9a\u4f4d\u5230\u66f4\u5c0f\u7684\u5355\u5143\uff1bDocument<\/a>\u5bf9\u8c61\u5411\u5916\u63d0\u4f9bSentences\u96c6\u5408\uff0c\u5141\u8bb8\u7528\u6237\u83b7\u53d6\u7531Application\u8bc6\u522b\u7684\u6307\u5411sentence\u5bf9\u8c61\u7684\u6587\u5b57\u533a\u57df\u3002\u4e0b\u9762\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cGet-DocumentSentences.ps1\u201d\u7684\u811a\u672c\u7528\u4e8e\u9010\u53e5\u8bfb\u53d6\u6587\u6863\u5185\u5bb9\uff0c\u5176\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>$wordApp = New-Object -COM Word.Application<\/p>\n<p>$file = (dir Sample.doc).FullName<\/p>\n<p>$doc = $wordApp.Documents.Open($file)<\/p>\n<p>$sentences = $doc.Sentences<\/p>\n<p>foreach ($sentence in $sentences)<\/p>\n<p>{<\/p>\n<p>Write-Host &quot;Sentence:&quot;<\/p>\n<p>Write-Host $sentence.Text<\/p>\n<p>}<\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u548c\u524d\u9762\u5173\u4e8e\u6bb5\u843d\u7684\u811a\u672c\u5f88\u76f8\u4f3c\uff0c\u552f\u4e00\u4e0d\u540c\u662fSentences\u96c6\u5408\u5305\u542b\u539f\u59cb\u7684Range\u5bf9\u8c61\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u50cfParagraph\u90a3\u6837\u91c7\u7528\u5355\u72ec\u7684Range\u5bf9\u8c61\u5b58\u50a8\u3002\u811a\u672c\u6267\u884c\u7ed3\u679c\u5982\u56fe4\u6240\u793a\uff0c\u80fd\u591f\u770b\u5230\u4e4b\u524d\u7684\u6587\u6863\u4e2d\u5728\u4e24\u6bb5\u6587\u5b57\u4e4b\u95f4\u6709\u4e2a\u5355\u72ec\u7684\u56de\u8f66\u7b26\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u6bb5\u3002\u5728\u9010\u53e5\u8bfb\u53d6\u65f6\u5e76\u6ca1\u6709\u770b\u5230\u6709\u7a7a\u767d\u7684sentence\u8f93\u51fa\uff0c\u5373\u6ca1\u6709\u8f93\u51fa\u3002<a name=\"OLE_LINK2\">\u53ef\u4ee5\u731c\u60f3\u8fd9\u91cc\u53e5\u5b50\u7684\u5206\u5272\u901a\u8fc7\u53e5\u70b9\uff08<\/a>.\uff09\u6765\u5b9e\u73b0\u3002\u7531\u4e8e\u7a7a\u884c\u4e2d\u4e0d\u5305\u542b\u53e5\u70b9\uff0c\u6240\u4ee5\u518d\u6309\u7167\u53e5\u5b50\u8f93\u51fa\u65f6\u8be5\u884c\u88ab\u5ffd\u7565\u3002\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u5728Word\u6587\u6863\u7684\u7a7a\u884c\u4e2d\u6dfb\u52a0\u53e5\u70b9\uff0c\u53ef\u4ee5\u9884\u6599\u5728\u539f\u6709\u7a7a\u884c\u7684\u4f4d\u7f6e\u4f1a\u6709\u5355\u72ec\u7684\u53e5\u70b9\u4ee5\u53e5\u5b50\u5185\u5bb9\u7684\u5f62\u5f0f\u51fa\u73b0\u3002<\/p>\n<\/p>\n<p align=\"center\"><a href=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image6.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px\" height=\"442\" alt=\"image\" src=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image_thumb5.png\" width=\"673\" border=\"0\" \/><\/a> <\/p>\n<p align=\"center\">\u56fe4 \u6267\u884c\u7ed3\u679c<\/p>\n<p>\u5728\u62c6\u5206\u5230\u53e5\u5b50\u7684\u5c42\u6b21\u540e\uff0c\u6587\u5b57\u4e3a\u80fd\u591f\u4eceWord\u4e2d\u8bfb\u53d6\u7684\u6700\u5c0f\u5355\u5143\u3002\u5728\u8fd9\u91cc\u9700\u8981\u8bfb\u53d6Words\u96c6\u5408\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cGet-DocumentWords.ps1\u201d\u7684\u811a\u672c\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>$wordApp = New-Object -COM Word.Application<\/p>\n<p>$file = (dir Sample.doc).FullName<\/p>\n<p>$doc = $wordApp.Documents.Open($file)<\/p>\n<p>$words = $doc.Words<\/p>\n<p>$words | select Text<\/p>\n<p>$wordApp.Quit()<\/p>\n<p>Words\u96c6\u5408\u8fd4\u56de\u4e00\u7cfb\u5217Range\u5bf9\u8c61\uff0c\u524d\u9762\u811a\u672c\u8fd4\u56de\u7684\u6587\u5b57\u533a\u57df\u5bf9\u8c61\u662f\u5355\u8bcd\u7684\u96c6\u5408\uff0c\u8be5\u811a\u672c\u7684\u6267\u884c\u7ed3\u679c\u5982\u56fe5\u6240\u793a\u3002<\/p>\n<p align=\"center\"><a href=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image7.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px\" height=\"442\" alt=\"image\" src=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image_thumb6.png\" width=\"673\" border=\"0\" \/><\/a> <\/p>\n<p align=\"center\">\u56fe5 \u6267\u884c\u7ed3\u679c<\/p>\n<p>\u80fd\u591f\u770b\u5230\u6309\u7167\u5355\u8bcd\u62c6\u5206\u5305\u542b\u7684\u6587\u5b57\uff0c\u62c6\u5206\u4f7f\u7528\u7a7a\u683c\u5b57\u7b26\u3002\u4f7f\u75283\u4e2a\u53e5\u70b9\uff08\u2026\uff09\u6765\u4ee3\u8868\u56de\u8f66\u7684\u4f4d\u7f6e\uff0c\u8fd9\u6837\u53ef\u4ee5\u901a\u8fc7\u8f93\u51fa\u7684\u6587\u5b57\u770b\u51fa\u6574\u4e2a\u5355\u8bcd\u6784\u6210\u7684\u53e5\u5b50\u548c\u6bb5\u843d\u7684\u5f62\u5f0f\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u5728\u5176\u4e2d\u7684\u7a7a\u884c\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u5230\u591a\u4e2a\u4e0d\u7b49\u7684\u53e5\u70b9\u548c\u7a7a\u683c\u7684\u6df7\u5408\u5b57\u7b26\u4e32\u6765\u9a8c\u8bc1\u662f\u5426\u662f\u6309\u7167\u7a7a\u683c\u6765\u62c6\u5206\u5355\u8bcd\uff1b\u53e6\u5916\u4e0a\u8ff0\u4ee5\u53e5\u70b9\u4ee3\u8868\u53e5\u5b50\u7ed3\u675f\uff0c\u4ee53\u4e2a\u53e5\u70b9\u4ee3\u8868\u6bb5\u843d\u56de\u8f66\u7684\u65b9\u5f0f\u6765\u901a\u8fc7\u62c6\u5206\u540e\u7684\u5355\u8bcd\u6784\u6210\u53cd\u5411\u8bfb\u51fa\u53e5\u5b50\u7684\u65ad\u53e5\uff0c\u4ee5\u53ca\u6bb5\u843d\u7684\u62c6\u5206\u65b9\u5f0f\u5e76\u4e0d\u7edd\u5bf9\u6b63\u786e\u3002\u56e0\u4e3a\u5982\u679c\u5728\u53e5\u5b50\u4e2d\u8fde\u7eed\u51fa\u73b0\u7528\u7a7a\u683c\u5206\u9694\u76843\u4e2a\u53e5\u70b9\uff0c\u5219\u53ef\u80fd\u88ab\u8bef\u5224\u4e3a\u4e24\u4e2a\u56de\u8f66\u7b26\u3002<\/p>\n<p><strong>\uff082\uff09\u521b\u5efa\u548c\u4fee\u6539\u6587\u6863<\/strong><\/p>\n<p>\u6587\u5b57\u533a\u57df\u5bf9\u8c61\u53ef\u4ee5\u7528\u6765\u83b7\u53d6\u53ea\u8bfb\u72b6\u6001\u4e0b\u7684\u6587\u6863\u5185\u5bb9\uff0c\u540c\u65f6\u4e5f\u53ef\u7528\u6765\u5199\u5165\u5e76\u4fee\u6539\u6587\u6863\u5185\u5bb9\u53ca\u683c\u5f0f\u3002\u8fd9\u91cc\u4f7f\u7528Document.Content\u83b7\u53d6\u6587\u5b57\u533a\u57df\u5185\u5bb9\uff0c\u5e76\u4f7f\u7528\u901a\u8fc7\u8bbe\u7f6eText\u5c5e\u6027\u63a7\u5236\u5185\u5bb9\u7684\u683c\u5f0f\u3002\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cNew-Document.ps1\u201d\u7684\u811a\u672c\uff0c\u8be5\u811a\u672c\u4f1a\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\u3002\u5176\u4e2dpath\u7528\u4e8e\u4fdd\u5b58\u6587\u6863\u7684\u4f4d\u7f6e\uff0ctext\u7528\u4e8e\u4fdd\u5b58\u6587\u4ef6\u5185\u5bb9\u3002\u8fd9\u4e2a\u811a\u672c\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>param ($path, $text)<\/p>\n<p>$wordApp = New-Object -COM Word.Application<\/p>\n<p>#delete the file if it already exists<\/p>\n<p>if (Test-Path $path)<\/p>\n<p>{<\/p>\n<p>del $path<\/p>\n<p>}<\/p>\n<p>$doc = $wordApp.Documents.Add()<\/p>\n<p>$doc.Content.Text = $text<\/p>\n<p>$doc.SaveAs($path)<\/p>\n<p>$wordApp.Quit()<\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u8c03\u7528Document.Add()\u65b9\u6cd5\u901a\u77e5Word\u521b\u5efa\u5fc3\u7684\u6587\u6863\u5bf9\u8c61\u3002\u4e00\u65e6text\u7684\u5185\u5bb9\u88ab\u8d4b\u7ed9Content\u6587\u672c\u5e8f\u5217\uff0c\u5c06\u4f1a\u8c03\u7528SaveAs()\u65b9\u6cd5\u5c06\u6587\u6863\u5199\u5165\u5230\u78c1\u76d8\u4e2d\u3002\u811a\u672c\u7684\u6267\u884c\u7ed3\u679c\u5982\u56fe6\u6240\u793a\u3002<\/p>\n<p align=\"center\"><a href=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image8.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px\" height=\"442\" alt=\"image\" src=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image_thumb7.png\" width=\"673\" border=\"0\" \/><\/a> <\/p>\n<p align=\"center\">\u56fe6 \u6267\u884c\u7ed3\u679c<\/p>\n<p>\u5199\u5165\u6587\u6863\u6253\u5f00\u540e\u7684\u7ed3\u679c\u5982\u56fe7\u6240\u793a\u3002<\/p>\n<p align=\"center\"><a href=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image9.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px\" height=\"363\" alt=\"image\" src=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image_thumb8.png\" width=\"644\" border=\"0\" \/><\/a> <\/p>\n<p align=\"center\">\n<p align=\"center\">\u56fe7 \u901a\u8fc7COM\u5199\u5165\u6587\u6863\u6253\u5f00\u540e\u7684\u7ed3\u679c<\/p>\n<p>\u4e3a\u6253\u5f00\u5e76\u4fee\u6539\u73b0\u6709\u6587\u6863\uff0c\u9700\u8981\u6253\u5f00\u6587\u6863\u5e76\u5b9a\u4f4d\u5230\u9700\u8981\u4fee\u6539\u7684\u5b57\u7b26\u533a\u57df\uff0c\u7136\u540e\u4fee\u6539\u5176\u4e2d\u7684\u5185\u5bb9\u548c\u683c\u5f0f\u5e76\u4fdd\u5b58\u3002\u4e0b\u9762\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cInsert-RedText.ps1\u201d\u7684\u811a\u672c\u7528\u4e8e\u6253\u5f00\u73b0\u6709\u6587\u6863\uff0c\u6dfb\u52a0\u4e00\u4e9b\u6587\u5b57\u5e76\u5c06\u5b57\u4f53\u989c\u8272\u6539\u4e3a\u7ea2\u8272\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>$wordApp = New-Object -COM Word.Application<\/p>\n<p>$file = (dir NewDocTest.doc).FullName<\/p>\n<p>$doc = $wordApp.Documents.Open($file)<\/p>\n<p>$documentFront = $doc.Content<\/p>\n<p>$documentFront.End = $start.Start<\/p>\n<p>$documentFront.Text =&quot;IMPROTANT!!!please review!`n&quot;<\/p>\n<p>$documentFront.Font.Name=&quot;Times new roman&quot;<\/p>\n<p>$documentFront.Font.ColorIndex = 6<\/p>\n<p>$doc.save()<\/p>\n<p>$wordApp.Quit()<\/p>\n<p>\u5176\u4e2d\u9996\u5148\u83b7\u53d6\u6587\u6863\u5185\u5bb9\u7684\u6587\u5b57\u533a\u57df\uff0c\u5e76\u5c06 End\u5c5e\u6027\u8bbe\u5b9a\u4e3aStart\u6240\u5305\u542b\u7684\u5185\u5bb9\u3002\u7c7b\u4f3c\u5728\u6587\u6863\u5f00\u5934\u521b\u5efa\u4e86\u4e00\u4e2a\u96f6\u957f\u5ea6\u7684\u5b57\u7b26\u533a\u57df\uff0c\u8fd9\u65f6\u53ef\u4ee5\u5c06\u5149\u6807\u653e\u7f6e\u5728\u6587\u6863\u5f00\u5934\u3002\u7136\u540e\u8bbe\u7f6eText\u5c5e\u6027\u5728\u6587\u6863\u5f00\u5934\u63d2\u5165\u6587\u5b57\uff0c\u4f7f\u7528\u6587\u5b57\u533a\u57df\u5bf9\u8c61\u6539\u53d8\u6587\u5b57\u7684\u5b57\u4f53\u5e76\u8bbe\u7f6e\u6587\u5b57\u989c\u8272\uff0c\u5176\u4e2d\u7d22\u5f15\u503c\u4e3a6\u4ee3\u8868\u7ea2\u8272\u3002\u6700\u540e\u901a\u8fc7Save()\u65b9\u6cd5\u4fdd\u5b58\u6587\u4ef6\u3002\u4e0a\u8ff0\u811a\u672c\u7684\u6267\u884c\u7ed3\u679c\u5982\u56fe8\u6240\u793a\u3002<\/p>\n<p align=\"center\"><a href=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image10.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px\" height=\"442\" alt=\"image\" src=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image_thumb9.png\" width=\"673\" border=\"0\" \/><\/a> <\/p>\n<p align=\"center\">\u56fe8 \u6267\u884c\u7ed3\u679c<\/p>\n<p>\u5199\u5165\u6587\u6863\u6253\u5f00\u540e\u7684\u7ed3\u679c\u5982\u56fe9\u6240\u793a\u3002<\/p>\n<p align=\"center\"><a href=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image11.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px\" height=\"363\" alt=\"image\" src=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image_thumb10.png\" width=\"644\" border=\"0\" \/><\/a> <\/p>\n<p align=\"center\">\u56fe9 \u5199\u5165\u6587\u6863\u6253\u5f00\u540e\u7684\u7ed3\u679c<\/p>\n<p>\u8c03\u8bd5\u65f6\u663e\u793aWord\u7a97\u53e3<\/p>\n<p>\u5728\u811a\u672c\u4e2d\u8c03\u7528Word\u7684\u81ea\u52a8\u5316\u64cd\u4f5c\u4e0d\u663e\u793a\u7a0b\u5e8f\u7a97\u53e3\uff0c\u7528\u6237\u770b\u4e0d\u5230\u4efb\u4f55\u7a97\u53e3\u3002\u6240\u6709\u4efb\u52a1\u5747\u5728\u540e\u53f0\u5b8c\u6210\uff0c\u8fd9\u6837\u5728\u8c03\u8bd5\u4ee3\u7801\u65f6\u975e\u5e38\u4e0d\u65b9\u4fbf\u3002\u4e3a\u4e86\u80fd\u591f\u6709\u6548\u5730\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u7528\u6237\u53ef\u4ee5\u8bbe\u7f6eWord\u5728\u6267\u884c\u65f6\u663e\u793a\u7a97\u53e3\u3002\u8fd9\u6837\u5373\u53ef\u591f\u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\u65e2\u80fd\u770b\u5230\u4ee3\u7801\u8fde\u7eed\u6267\u884c\uff0c\u53c8\u80fd\u770b\u5230\u6267\u884c\u7684\u8fc7\u7a0b\u3002<\/p>\n<p>\u4e3a\u4e86\u5f3a\u5236\u4e3b\u7a0b\u5e8f\u7a97\u53e3\u5728\u8fd0\u884c\u65f6\u53ef\u89c1\uff0c\u53ea\u9700\u8981\u8bbe\u7f6eApplication\u5bf9\u8c61\u7684Visible\u5c5e\u6027\u4e3a$true\u3002\u901a\u8fc7\u4e4b\u524d\u5728\u811a\u672c\u4e2d\u8bbe\u5b9a\u7684\u53d8\u91cf\u540d\uff0c\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u7684\u4efb\u610f\u4f4d\u7f6e\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>$wordApp.Visible = $true<\/p>\n<p>\u5728\u4ee3\u7801\u8c03\u8bd5\u6b63\u5e38\u540e\u52a1\u5fc5\u8981\u5220\u9664\u8fd9\u6761\u4ee3\u7801\uff0c\u4f7f\u7a0b\u5e8f\u6b63\u786e\u6267\u884c\u3002<\/p>\n<p><strong>\uff083\uff09\u4f7f\u7528\u62fc\u5199\u68c0\u67e5<\/strong><\/p>\n<p>Word\u7684\u62fc\u5199\u68c0\u67e5\uff08spell-checker\uff09\u652f\u6301\u901a\u8fc7COM\u81ea\u52a8\u5316\u8c03\u7528\uff0c\u5728\u4f7f\u7528\u65f6\u53ea\u9700\u6dfb\u52a0\u4e00\u4e9b\u6587\u5b57\u5e76\u83b7\u53d6Document\u7684SpellingErrors\u5c5e\u6027\u503c\uff0c\u8fd9\u4e2a\u5c5e\u6027\u4f1a\u6536\u96c6\u5305\u542b\u9519\u8bef\u6587\u672c\u6bb5\u7684\u6587\u5b57\u533a\u57df\u5bf9\u8c61\u96c6\u5408\u3002\u4e00\u65e6\u4e00\u4e2a\u6587\u5b57\u533a\u57df\u5305\u542b\u9519\u8bef\u7684\u5355\u8bcd\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528Range\u5bf9\u8c61\u7684GetSpellingSuggestions()\u65b9\u6cd5\u83b7\u53d6\u66f4\u6b63\u5efa\u8bae\u3002\u8fd9\u4e2a\u65b9\u6cd5\u7684\u8fd4\u56de\u503c\u662fSpellingSuggestion\u5bf9\u8c61\uff0c\u5176Name\u5c5e\u6027\u503c\u5305\u542b\u66f4\u6b63\u5efa\u8bae\u3002<\/p>\n<p>\u4e3a\u4e86\u6f14\u793a\u62fc\u5199\u68c0\u67e5\u529f\u80fd\uff0c\u5728\u8fd9\u91cc\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cSpellCheck-Text.ps1\u201d\u7684\u811a\u672c\uff0c\u5728\u53d1\u73b0\u62fc\u5199\u9519\u8bef\u540e\u63d0\u51fa\u66f4\u6b63\u5efa\u8bae\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>$wordApp = New-Object -COM Word.Application<\/p>\n<p>$doc = $wordApp.Documents.Add()<\/p>\n<p>$doc.Content.Text = &quot;this is some text with mistakn and errros&quot;<\/p>\n<p>$errors = $doc.SpellingErrors<\/p>\n<p>foreach ($errorRange in $errors)<\/p>\n<p>{<\/p>\n<p>Write-Host &quot;Error: $($errorRange.Text)&quot;<\/p>\n<p>$suggestions = ($errorRange.GetSpellingSuggestions())<\/p>\n<p>$suggestedWords =$suggestions | foreach {$_.Name}<\/p>\n<p>Write-Host &quot;Suggestions :&quot;<\/p>\n<p>Write-Host $suggestedWords<\/p>\n<p>}<\/p>\n<p>$wordApp.Quit()<\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u901a\u8fc7\u83b7\u53d6\u6bcf\u4e2a\u6587\u5b57\u533a\u57df\u4e2d\u9519\u8bef\u7684SpellingSuggestion\u5bf9\u8c61\uff0c\u5e76\u5c06\u5176\u5b58\u5165\u6570\u7ec4\u4e2d\u3002\u7136\u540e\u5c06\u96c6\u5408\u7528\u7ba1\u9053\u4f20\u9012\u7ed9foreach cmdlet\uff0c\u5206\u522b\u5c06\u96c6\u5408\u4e2d\u5305\u542b\u7684Name\u5c5e\u6027\u7684\u503c\uff0c\u6267\u884c\u7ed3\u679c\u5982\u56fe10\u6240\u793a\u3002<\/p>\n<p align=\"center\"><a href=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image12.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px\" height=\"442\" alt=\"image\" src=\"http:\/\/txj.shell.tor.hu\/wp-content\/uploads\/2010\/12\/image_thumb11.png\" width=\"673\" border=\"0\" \/><\/a> <\/p>\n<p align=\"center\">\u56fe10 \u6267\u884c\u7ed3\u679c<\/p>\n<\/p>\n<p><strong>\uff084\uff09\u83b7\u53d6\u5e2e\u52a9<\/strong><\/p>\n<p>\u672c\u8282\u4e2d\u6240\u6709\u7684\u6d89\u53caWord\u7684COM\u63a5\u53e3\u7684\u5185\u5bb9\u90fd\u4ee5\u6d45\u5c1d\u8f84\u6b62\u7684\u5f62\u5f0f\u8fdb\u884c\uff0c\u56e0\u4e3aMicrosoft Office\u81ea\u52a8\u5316\u7684\u529f\u80fd\u975e\u5e38\u5f3a\u5927\u8fdc\u975e\u4e00\u672c\u4e66\u53ef\u4ee5\u5199\u5b8c\u3002\u8fd9\u91cc\u6240\u6d89\u53ca\u7684\u5185\u5bb9\u90fd\u662f\u4e3a\u5e7f\u5927\u8bfb\u8005\u6253\u5f00\u77e5\u8bc6\u7684\u5927\u95e8\uff0c\u5176\u4ed6\u66f4\u5177\u4f53\u7684\u5185\u5bb9\u8fd8\u9700\u8981\u8bfb\u8005\u5728\u5b66\u4e60\u548c\u5de5\u4f5c\u4e2d\u638c\u63e1\u3002\u6709Microsoft Office\u81ea\u52a8\u5316\u7f16\u7a0b\u80cc\u666f\u7ecf\u9a8c\u7684\u811a\u672c\u4f5c\u8005\u548c\u7528\u6237\u5bf9\u4e8e\u811a\u672c\u4e2d\u63d0\u5230\u7684\u5bf9\u8c61\u5e94\u8be5\u6bd4\u8f83\u719f\u6089\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u5bf9\u8c61\u548cVBA\u7f16\u7a0b\u73af\u5883\u9488\u5bf9\u7684COM\u63a5\u53e3\u5b8c\u5168\u76f8\u540c\u3002VBA\u7f16\u7a0b\u8bed\u8a00\u7684\u8bed\u6cd5\u7ed3\u6784\u5b8c\u5168\u4e0d\u540c\u4e8ePowerShell\uff0c\u4f46\u662f\u7edd\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u5c06VBA\u7684\u7a0b\u5e8f\u7ffb\u8bd1\u4e3aPowerShell\u7684\u811a\u672c\u975e\u5e38\u5bb9\u6613\uff0c\u56e0\u4e3a\u6240\u6709\u7684\u65b9\u6cd5\u3001\u5c5e\u6027\u548c\u64cd\u4f5c\u8bed\u6cd5\u57fa\u672c\u76f8\u540c\u3002\u5982\u679c\u611f\u5174\u8da3\uff0c\u53ef\u4ee5\u4f7f\u7528\u300aMicrosoft Word Visual Basic Reference\u300b\u4e2d\u7684Word\u90e8\u5206\u7684\u5e2e\u52a9\u6765\u83b7\u53d6\u81ea\u52a8\u5316\u5bf9\u8c61\u548c\u5c5e\u6027\u7684\u8be6\u7ec6\u4ecb\u7ecd\u3002<\/p>\n<p>Microsoft Office\u81ea\u52a8\u5316\u8fd8\u6709\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\u53ef\u4ee5\u7528\u6765\u5feb\u901f\u751f\u6210\u4ee3\u7801\uff0c\u8fd9\u5c31\u662f\u5b8f\uff08macro\uff09\u8bb0\u5f55\u5de5\u5177\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u5f55\u5236\u81ea\u5df1\u7684\u64cd\u4f5c\u6765\u751f\u6210\u5b8f\uff0c\u5e76\u7528Visual Basic \u4ee3\u7801\u7f16\u8f91\u5668\u6253\u5f00\u5b8f\u3002Word\u5c06\u4f1a\u6839\u636e\u4e4b\u524d\u5f55\u5236\u7684\u5b8f\u751f\u6210Visual Basic\u4ee3\u7801\uff0c\u5c06\u8fd9\u4e9b\u4ee3\u7801\u7ffb\u8bd1\u4e3aPowerShell\u7684\u811a\u672c\u3002<\/p>\n<p>\u672c\u8282\u4e2d\u6211\u4eec\u66fe\u7ecf\u901a\u8fc7\u6784\u9020\u7279\u5b9a\u5b57\u7b26\u4e32\u6765\u7aa5\u89c6PowerShell\u7684\u4e00\u4e9b\u5e95\u5c42\u64cd\u4f5c\u7684\u601d\u8def\uff0c\u5bf9\u4e8e\u7f16\u7a0b\u4eba\u5458\u6765\u8bf4\u5f88\u91cd\u8981\u3002\u5f88\u591a\u65f6\u5019\u4e00\u4e9b\u7cfb\u7edf\u9700\u8981\u9ed1\u76d2\u65b9\u5f0f\u5206\u6790\uff0c\u9700\u8981\u901a\u8fc7\u8f93\u5165\/\u8f93\u51fa\u6765\u6821\u9a8c\u81ea\u5df1\u7684\u4e00\u4e9b\u601d\u8def\u3002\u8fdb\u800c\u4e00\u6b65\u6b65\u5c06\u8f6f\u4ef6\u7cfb\u7edf\u6309\u7167\u81ea\u5df1\u7684\u7406\u89e3\u642d\u5efa\u8d77\u6765\u3002\u4e5f\u8bb8\u5176\u4e2d\u7684\u4ee3\u7801\u5e76\u4e0d\u80fd\u548c\u7cfb\u7edf\u672c\u8eab\u7684\u4ee3\u7801\u5b8c\u5168\u543b\u5408\uff0c\u4f46\u5177\u4f53\u7684\u529f\u80fd\u5374\u53ef\u4ee5\u7531\u6b64\u6a21\u4eff\u51fa\u6765\u3002<\/p>\n<p>&#160;<\/p>\n<p>\u4f5c\u8005: \u4ed8\u6d77\u519b   <br \/>\u7248\u6743\uff1a\u672c\u6587\u7248\u6743\u5f52\u4f5c\u8005\u6240\u6709    <br \/>\u8f6c\u8f7d\uff1a\u6b22\u8fce\u8f6c\u8f7d\uff0c\u4e3a\u4e86\u4fdd\u5b58\u4f5c\u8005\u7684\u521b\u4f5c\u70ed\u60c5\uff0c\u8bf7\u6309\u8981\u6c42\u3010\u8f6c\u8f7d\u3011\uff0c\u8c22\u8c22    <br \/>\u8981\u6c42\uff1a\u672a\u7ecf\u4f5c\u8005\u540c\u610f\uff0c\u5fc5\u987b\u4fdd\u7559\u6b64\u6bb5\u58f0\u660e\uff1b\u5fc5\u987b\u5728\u6587\u7ae0\u4e2d\u7ed9\u51fa\u539f\u6587\u8fde\u63a5\uff1b\u5426\u5219\u5fc5\u7a76\u6cd5\u5f8b\u8d23\u4efb     <br \/>\u4e2a\u4eba\u7f51\u7ad9: <a href=\"http:\/\/txj.shell.tor.hu\/\">http:\/\/txj.shell.tor.hu\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e3b\u8981\u63cf\u8ff0\u4e86COM\u6a21\u578b\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u4ee5\u53ca\u5728powershell\u4e2d\u5982\u4f55\u8c03\u7528COM\uff0c\u672c\u7bc7\u6587\u7ae0\u4e2d\u5c06\u4f1a\u7740\u91cd\u4ecb\u7ecdp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-33207","post","type-post","status-publish","format-standard","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/33207"}],"collection":[{"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=33207"}],"version-history":[{"count":1,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/33207\/revisions"}],"predecessor-version":[{"id":33776,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/33207\/revisions\/33776"}],"wp:attachment":[{"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=33207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=33207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fuhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=33207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}