$excel_test = New-Object -ComObject Excel.Application
$excel_test.visible =$false
$excel_test.DisplayAlerts =$true
$excelFiles = Get-ChildItem -Path C:\Users\Lab-User\Documents\NDVI_2_Working -Include *.xlsx -Recurse
Foreach ($file in $excelFiles)
{
$workbook = $excel_test.Workbooks.open($file)
$Worksheet = $Workbook.WorkSheets.item("Sheet2")
$range = $WorkSheet.range("A1:AC1").EntireColumn
$averages=$range.Copy("AB1").EntireColumn
$averages.SaveAs("C:\Users\Lab-User\Documents\NDVI_2_Working\Summary.xlsx")
}
我不断收到“范围类的复制方法失败”的错误。