$FolderPath = "C:\aaa\aaaa\aaa\Excel"
$excelFiles = Get-ChildItem -Path $FolderPath -Filter "*.xlsm" -File
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
foreach ($file in $excelFiles) {
Write-Host $file
$workbook = $excel.Workbooks.Open($file.FullName)
foreach ($worksheet in $workbook.Worksheets) {
$worksheet.Cells.Interior.ColorIndex = -4142 # 背景色を塗りつぶしなしに設定する
# オートシェイプ(図形)の背景も塗りつぶしなしに設定する場合、以下のコメントを解除してください
# $worksheet.Shapes | ForEach-Object { $_.Fill.Visible = $false }
}
$workbook.Save()
$workbook.Close()
}
$excel.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null