Created
February 10, 2021 09:20
-
-
Save stevehansen/8590e4c8456dab81cab772221efe4520 to your computer and use it in GitHub Desktop.
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
# https://stackoverflow.com/a/16537996/295296 | |
$documents_path = 'c:\doc2pdf' | |
$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