title: Output Array to Specific Worksheet in Excel uisng PowerShell
body: <p>I have an array in PowerShell called "$OutArray"
  The array is filled with multiple emails that I need to output into each cell in Excel in the very first column.  The sheet is labeled "Reporters".  </p>
  
  <p>I use the following for loop to try to output each item in the array:</p>
  
  <pre><code>$Excel = New-Object -ComObject Excel.Application
  $ExcelWorkBook = $Excel.Workbooks.Open($excel_file_path)
  $ExcelWorkSheet = $Excel.WorkSheets.Item("Reporters")
  $ExcelWorkSheet.activate()
  
  for ($i = 0; $i -lt $OutArray.Length; $i++) {
      $ExcelWorkSheet.Cells.Item($i, 1) = $OutArray[$i]
  } 
  </code></pre>
  
  <p>Btw, $excel_file_path is already declared properly.</p>
  
  <p>However, I receive the following error:</p>
  
  <p><a href="https://i.stack.imgur.com/Gp1ki.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gp1ki.png" alt="PowerShell Error"></a></p>
  
  <p>I was able to output the array in a new workbook by the following command:</p>
  
  <pre><code>$OutArray | out-file "C:\desiredPathHere"
  </code></pre>
  
  <p>but I'm trying to append to an existing workbook in a new sheet.</p>
  
  <p>Any hints?</p>
  
  <p>Thanks everyone.</p>