Skip to content

Instantly share code, notes, and snippets.

@tckz
Created July 27, 2010 10:03
Show Gist options
  • Select an option

  • Save tckz/492005 to your computer and use it in GitHub Desktop.

Select an option

Save tckz/492005 to your computer and use it in GitHub Desktop.
powershellでword文書をhtml一括保存
[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