$excelFiles = Get-ChildItem -Path "C:\path\to\folder" -Filter *.xlsx -Recurse
foreach ($file in $excelFiles) {
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
$workbook = $excel.Workbooks.Open($file.FullName)
foreach ($worksheet in $workbook.Worksheets) {
$range = $worksheet.UsedRange
$result = $range.Find("search_text")
if ($result) {
Write-Host "File: $($file.FullName), Sheet: $($worksheet.Name), Cell: $($result.Address)"
}
}
$workbook.Close($false)
$excel.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel)
}
処理中断 Ctrl + C またはウィンドウを閉じる