-1
以下程序在文件夹位置“c:\ mfolder”中的一组文件上运行PowerShell中名为“Macro1”的Excel VBA宏。我怎样才能复制它的Word VBA宏?Word VBA宏通过Powershell
***** runexcel.ps1 ******
$excel = new-object -comobject excel.application
$excelFiles = Get-ChildItem -Path C:\mfolder -Include *.xls -Recurse
Foreach($file in $excelFiles)
{
$workbook = $excel.workbooks.open($file.fullname)
$worksheet = $workbook.worksheets.item(1)
$excel.Run("Macro1")
$workbook.save()
$workbook.close()
}
$excel.quit()
请阅读此:http://stackoverflow.com/help/how-to-ask –