-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 –