I'm interested in how one supplies either a named argument to a ComObject function or how one supplies the default parameter without actually knowing the default value.
The task:
Using PowerShell, open a Word document in a headless mode (without the Word Window), change the document direction and save it as a PDF file.
The problem
As per the function documentation, the parameter setting the document direction is roughly the 15th optional parameter. I either need to supply the preceding 14 parameters with their default value (which I so far could't figure how to do) or, better, I'd like to use something like VB's
Documents.Open FileName:="C:\MyFiles\Test.wp", DocumentDirection:=false
Other possibility were
$doc = $word.Documents.Open($file, $default, $default, ..., $default, wdLeftToRight)
but that is clearly the inferior solution.
Minimal source This is what I have and it works fine except for the direction part.
$file=$args[0]
$outputFile=$args[1]
$word = New-Object -ComObject word.application
$doc = $word.Documents.Open $file
$doc.SaveAs([ref] $outputFile, [ref] 17)
$doc.Close()
$word.Quit()