Created
July 27, 2010 10:03
-
-
Save tckz/492005 to your computer and use it in GitHub Desktop.
powershellでword文書をhtml一括保存
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [reflection.assembly]::LoadWithPartialName("Microsoft.Office.Interop.Word") | out-null | |
| $word = new-object Microsoft.Office.Interop.Word.ApplicationClass | |
| $word.Visible = $true | |
| foreach($arg in $args) | |
| { | |
| foreach($doc in (Get-Item $arg)) | |
| { | |
| $fn_doc = $doc.FullName | |
| $word_doc = $word.Documents.Open($fn_doc, $false, $false) | |
| $word_doc.Activate() | |
| $ext = $doc.Extension | |
| $wo_ext = $fn_doc.Substring(0, $fn_doc.Length - $ext.Length) | |
| $fn_html = $wo_ext + ".html" | |
| $word_doc.SaveAs([ref]$fn_html, [ref][Microsoft.Office.Interop.Word.WdSaveFormat]::wdFormatFilteredHTML) | |
| } | |
| } | |
| $word.Quit() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment