Reputation: 468
How does one specify the options?
This works $workbook.worksheets.Add()
but I want to specify a worksheet to add this new one after. That's the second of four possible options:.Add(Before, After, Count, Type). I can't seem to figure out what the proper syntax in Powershell is. If I get it wrong, there's no error, but the worksheet is not created. For example, $workbook.worksheets.Add(,$lastSheet)
does not work. $lastSheet of course is a sheet object. I instantiated that with $sheet = $workbook.ActiveSheet
$lastSheet = $sheet
Upvotes: 2
Views: 6004
Reputation: 468
$workbook.worksheets.Add([System.Reflection.Missing]::Value,$lastsheet)
Apparently the [System.Reflection.Missing]::Value
can be used to represent a value in this kind of construction because a null is not allowed.
Upvotes: 3