Created
April 27, 2018 07:01
-
-
Save szymonk92/d69dc0947bd2dfcb6e93296b4e4689b6 to your computer and use it in GitHub Desktop.
This file contains 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
$documents_path = '.' | |
$word_app = New-Object -ComObject Word.Application | |
# This filter will find .doc as well as .docx documents | |
Get-ChildItem -Path $documents_path -Filter *.doc? | ForEach-Object { | |
$document = $word_app.Documents.Open($_.FullName) | |
$pdf_filename = "$($_.DirectoryName)\$($_.BaseName).pdf" | |
$document.SaveAs([ref] $pdf_filename, [ref] 17) | |
$document.Close() | |
} | |
$word_app.Quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment