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)

$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.


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