如何在Powershell中设置Excel“保存前重新计算工作簿”?

时间:2015-02-25 12:45:40

标签: excel powershell

在Powershell中,我可以通过以下方式将活动Excel应用程序的计算选项设置为手动:

$Excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
$xlCalculationManual = -4135
$Excel.Calculation = $xlCalculationManual

对于Excel"在保存之前是否重新计算工作簿"? 在VBA中,这可以通过

实现
Application.CalculateBeforeSave = True

但我在Powershell中需要这个......

1 个答案:

答案 0 :(得分:1)

看起来很简单:

$Excel.CalculateBeforeSave = $true