Ignoring warning/error popup messages for Excel script

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Chris Bakker Chris Bakker 10 months, 1 week ago.

  • Author
  • #33096
    Profile photo of Paps Sale
    Paps Sale

    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 🙂

  • #33110
    Profile photo of Matt Bloomfield
    Matt Bloomfield

    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.

  • #33156
    Profile photo of Paps Sale
    Paps Sale

    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.

  • #33292
    Profile photo of Chris Bakker
    Chris Bakker

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

You must be logged in to reply to this topic.