I'm pretty new to powershell I found a ps script that will convert old Microsoft Word 97, 2003, and 2007 documents from the extension .doc to the new Microsoft Word format extension .docx. I have over 100 old word documents from Users on our network.
Here's what I have:
[ref]$SaveFormat = “microsoft.office.interop.word.WdSaveFormat” -as [type]
$word = New-Object -ComObject word.application
$word.visible = $false
$folderpath = “c:\Users\user\desktop\username_old_docs"
$fileType = “*doc”
Get-ChildItem -path $folderpath -include $fileType |
foreach-object `
{
$path = ($_.fullname).substring(0,($_.FullName).lastindexOf(“.”))
“Converting $path to $fileType …”
$doc = $word.documents.open($_.fullname)
$doc.saveas([ref] $path, [ref]$SaveFormat::wdFormatDocumentDefault)
$doc.close()
}
$word.Quit()
$word = $null
[gc]::collect()
[gc]::WaitForPendingFinalizers()
When I run the ps1 script I'm getting this:
cmdlet ForEach-Object at command pipeline position 2
Supply values for the following parameters:
Process[0]:
I feel that I might be missing the path for when the files are converted as to where they will get saved. Any help would be greatly appreciated.
Thanks,
sothpaw