Respond to Excel prompts programatically

Welcome Forums General PowerShell Q&A Respond to Excel prompts programatically

Viewing 2 reply threads
  • Author
    Posts
    • #164346
      Participant
      Topics: 13
      Replies: 42
      Points: 243
      Rank: Participant

      I have a .xlsm file and I’m trying to convert it to a xlsx with the code below:

      $objExcel = New-Object -comobject excel.application
      $objExcel.Visible = $False
      $doc = $objExcel.WorkBooks.Open($path)
      $doc.SaveAs("$path\modified.xlsx",
      [Microsoft.Office.Interop.Excel.XlFileFormat]::xlOpenXMLWorkbook)
      $doc.close()
      
      $objExcel.Quit()
      $objExcel = $null

      The only problem is that excel prompts me with the GUI every time saying “The following features cannot be saved in macro-free workbooks…”. I don’t care though.

      How can I pipe a response to the prompt, as I would if there was a y/n confirmation in a cli command.

    • #164776
      Participant
      Topics: 13
      Replies: 42
      Points: 243
      Rank: Participant

      Bump

    • #165037
      Participant
      Topics: 24
      Replies: 175
      Points: 585
      Helping Hand
      Rank: Major Contributor

      i haven’t tested, but you could try piping it to out-null

Viewing 2 reply threads
  • The topic ‘Respond to Excel prompts programatically’ is closed to new replies.