[英]How to run parallel excel macros with PowerShell?
I would like to run multiple excel macros in parallel by opening multiple instances of excel using a shell (PowerShell) script. 我想通过使用Shell(PowerShell)脚本打开多个excel实例来并行运行多个excel宏。
Examples on parallel processing in shell aren't intuitive to me (new to shell scripting). 在我看来,关于shell中并行处理的示例并不直观(shell脚本的新功能)。
# start excel
$excel = New-Object -comobject Excel.Application
# get files
$files = Get-ChildItem "C:\User\test"
# loop through all files in the directory
ForEach ($file in $files){
# open the file
$workbook = $excel.Workbooks.Open($file.FullName)
# make file visible
$excel.Visible = $true
# run macro
$app = $excel.Application
$app.run("Macro1")
}
The code provided performs the task I want, but it does so sequentially rather than in parallel. 提供的代码执行了我想要的任务,但是它是顺序执行的,而不是并行执行的。
$app.run("application.ontime vba.now() + vba.timeserial(0,0,5),""Macro1"" ")
这将异步运行您的宏,但仍然不知道您是否要
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.