It is in Excel 2003 VBA
Application.Calculation = xlCalculationManual
I want to achieve the same in Powershell. It is what I did:
$excel = New-Object -com Excel.Application
$xlCalculationManual = -4135
$excel.Calculation = $xlCalculationManual
Value -4135 is obtained from there: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.constants%28v=office.14%29.aspx
It throws an exception:
Exception setting "Calculation": "Unable to set the Calculation property of the Application class"
At C:\Documents and Settings\AUser\Desktop\ppp2eikon.ps1:11 char:8
+ $excel. <<<< Calculation = $xlCalculationManual
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
What is the proper way to set this property?
At least in VBA, you can't set the calculation mode if there's not at least one open workbook. Error raised is: 1004 - Application-defined or object-defined error
Try opening a workbook first.