首页 > 解决方案 > 在通过powershell完全刷新之前保持excel打开?

问题描述

我正在使用这个powershell脚本打开一个excel,运行一个宏来刷新所有,保存并关闭。这工作正常,但在完全刷新 excel 之前,excel 正在保存和关闭。有没有办法我可以添加一个等待语句,以便它可以等到工作簿完全刷新。

$objectExcel = new-object -c excel.application
$objectExcel.displayAlerts = $false # don't prompt the user
$objectExcel.visible = $True;
#$objectExcel.visible = $True;
$Classeur = $objectExcel.workbooks.open("\\gbrmiteufs01.eu.xerox.net\SWG01\XOG-BORG\EBIP\POS Data\POS 
Data.xlsm", $null, $false)
$objectExcel.run("Workbook_RefreshAll")
$objectExcel.run("RemoveODBC") # another custom macro for removing data connecion
$Classeur.save()
$Classeur.close()
$objectExcel.quit()

标签: excelvbapowershell

解决方案


推荐阅读