繁体   English   中英

如何使用PowerShell运行并行Excel宏?

[英]How to run parallel excel macros with PowerShell?

我想通过使用Shell(PowerShell)脚本打开多个excel实例来并行运行多个excel宏。

在我看来,关于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")
}

提供的代码执行了我想要的任务,但是它是顺序执行的,而不是并行执行的。

$app.run("application.ontime vba.now() + vba.timeserial(0,0,5),""Macro1"" ")

这将异步运行您的宏,但仍然不知道您是否要

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM