Hi,
I have an excel macro file which contain multiple sheets in it.
Using the below code, I am trying to find out the sheets which contains specific string in it. The code is working fine as expected.
The problem is, whenever trying to open the macro excel file its showing a popup window(Microsoft Visual Basic) and
we suppose to click ‘end’ button to supress that window. But it will be a difficult one when processing thousands of Macro files.
I tried set the excel.DisplayAlerts = $false. But it didn’t even workout.
Please suggest a way the supress that window by the code itself. (Attached is the snapshot of the window, for reference)
$before = @(Get-Process [e]xcel | %{$_.Id}) $excel = New-Object -comobject Excel.Application $ExcelId = Get-Process excel | %{$_.Id} | ?{$before -notcontains $_} $excel.Visible = $false $excel.DisplayAlerts = $false $excel.AskToUpdateLinks = $false $workbook = $excel.Workbooks.Open('D:\dinesh\worksheetArea\workbook1.xlsm') For($i = 1 ; $i -le $workbook.Sheets.count ; $i++) { $worksheet = $workbook.sheets.item($i) $search = $worksheet.usedRange.Find('ServerId::50012') If($search){ $final_list += worksheet.Name } } if (!$Workbook.saved){ $workbook.save() } $workbook.close() $excel.quit() $excel = $null [gc]::collect() [gc]::WaitForPendingFinalizers()
Thanks
Dinesh