Skip to content

Instantly share code, notes, and snippets.

@fullyninja
Created August 30, 2016 05:10
Show Gist options
  • Save fullyninja/fb63726d999fd95f64596ebe82d4939b to your computer and use it in GitHub Desktop.
Save fullyninja/fb63726d999fd95f64596ebe82d4939b to your computer and use it in GitHub Desktop.
PowerShell Snippet to create empty Word documents given a text file with a list of file names.
$docListPath = "C:\temp\doclist.txt"
$docList = Get-Content $docListPath
$basePath = "c:\temp\docListOut\"
$word = New-Object -ComObject Word.Application
foreach ($fileName in $docList)
{
$outPath = "$basePath$filename"
Write-Host "Creating $outPath"
# Create a new document.
$word.Application.Documents.Add()
$word.Application.ActiveDocument.SaveAs([ref]$outPath)
$word.Application.ActiveDocument.Close()
}
$word.Application.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment