powershell and Excel

Welcome Forums General PowerShell Q&A powershell and Excel

Viewing 1 reply thread
  • Author
    • #253676
      Topics: 44
      Replies: 97
      Points: 605
      Rank: Major Contributor

      Dear all
      I’m working on a script to remove email addresses from an excel file
      the script as such works fine when I search for just 1 email address save and close. however when I work with multiple email addresses then I get a popup that this workbook is used by another process and I’m not able to edit the file to remove the other email addresss

      is there a way that I can run this without using multiple com objects?
      or do I need to close the com objects each and every time?



    • #253763
      Topics: 27
      Replies: 42
      Points: 394
      Rank: Contributor

      you are creating a new excel object inside the foreach loop, don’t do that. for each iteration of the loop, you try to create an object that already exists.

      create the object before the loop so that only one object will be created and work with that object.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.