0
我运行了一个powershell脚本,可以在后台打开excel文件,并在其上执行宏。麻烦在于运行需要很长时间,有时我忘记它正在运行并打开另一个excel实例,这会混淆脚本。在powershell脚本宏执行期间阻止excel打开
脚本中是否有阻止用户打开另一个excel文件的方法,或者是让脚本在后台执行并允许我在前台的另一个工作簿中工作?
下面是PowerShell脚本的相关部分:
# Open excel
$excel = new-object -comobject excel.application
$macro = $excel.workbooks.open("C:\Users\User\AppData\Roaming\Microsoft\Excel\XLSTART\PERSONAL.XLSB")
# Get list of files to parse
$files = Get-ChildItem -Path $PWD\*.csv
# ----execute macros----
# Close excel
$macro.close()
$excel.quit()