Ignoring warning/error popup messages for Excel script

This topic contains 3 replies, has 3 voices, and was last updated by  Chris Bakker 2 years, 7 months ago.

  • Author
  • #33096

    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

    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

    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

    Chris Bakker

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

You must be logged in to reply to this topic.