Ignoring warning/error popup messages for Excel script

I would like to know how to ignore warning/error popups while running Powershell for Excel com objects. However I’d still like the errors to be logged in the Powershell console (as it is with my current code below).

I’m running the following code as of now:

$files = Get-ChildItem -Path "D:\Product Feeds\" *.xlsx -Recurse
$xl = New-Object -ComObject Excel.Application
foreach ($file in $files) {

    $newFile = "$($file.DirectoryName)\$($file.BaseName).csv"
    $wb = $xl.Workbooks.Open($file.FullName)
    if (Test-Path -Path $newFile) {
        Remove-Item $newFile -Force

Thanks in advance :slight_smile:

Can you give us some idea of what the errors are and what the pop-ups say. I didn’t get any errors or pop-ups when testing this.

Hi Matt,

One error for example is that the import file excel is trying to retrieve does not exist, in which case I have to press OK.
The exact error message is:
“The internet address internet address is not valid”
and there’s an “OK” button to press and continue.

No errors here to.
What’s in the excel files?