Respond to Excel prompts programatically

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.

Bump

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