I'm trying to put in default/null/missing values for .printout
in PowerPoint but I can't get it to work. The value's that are giving me troubles are defined as integers in this page.
Usually I have been able to use [System.Type]::Missing
or ''
but neither of those work and I get the following:
Cannot convert the "System.Reflection.Missing" value of type "System.Reflection.Missing" to type "System.Int32".
How can I put in null values for those two params of .printout
for PowerPoint?
Here is what I have for code so far:
###PPT
IF ($FILETYPE -eq "PPT") {
ECHO "PPT_FOUND"
$msoFalse = [Microsoft.Office.Core.MsoTriState]::msoFalse
$msoTrue = [Microsoft.Office.Core.MsoTriState]::msoTrue
$ObjPPT = New-Object -comobject PowerPoint.Application
$ObjPPT.Visible = $msoTrue
#$ObjPPT.DisplayAlerts = $msoFalse
#Exception setting "DisplayAlerts": "Cannot convert value "msoFalse" to type "Microsoft.Office.Interop.PowerPoint.PpAlertLevel" due to enumeration values that are not valid. Specify one of the following
#enumeration values and try again. The possible enumeration values are "ppAlertsNone,ppAlertsAll"."
#.Open
$FILENAME = $FILEPATH
IF (!$ReadOnly){$ReadOnly = $msoTrue}
IF (!$Untitled){$Untitled = $missing}
IF ((!$WithWindow) -and ($OPENUI -eq "FALSE")){$WithWindow = $msoFalse} ELSE {$WithWindow = $msoTrue}
$ObjPresentation=$ObjPPT.Presentations.open($FILENAME,$ReadOnly,$Untitled,$WithWindow)
#.Print
#.PrintOut (From[Integer], To[Integer], PrintToFile[String], Copies [Integer], Collate[Bool]{msoTrue/False})
IF (!$From){[int]$From = $missing}
IF (!$To){[int]$To = $missing}
IF (!$PrintToFile){[string]$PrintToFile = $missing}
#Copies Defined Earlier
IF (!$Collate){$Collate = $msoTrue}
#$ObjPresentation.printout($From,$To,$PrintToFile,$COPIES,$Collate)
$ObjPresentation.printout($From,$To)# , ,$COPIES,$Collate)
#All Done
Sleep 2
$ObjPresentation.Close()
$ObjPPT.Quit()
Do-CloseIfRunning -Process $PROCESS
}
[gc]::collect()
[gc]::WaitForPendingFinalizers()
#Get-Variable
#PAUSE
Turns out using 0
caused an error, but using -1
for From/To
values worked as expected (null values).