Agreeing @TheMaster you cannot directly assign a parameter into the menu item, Using the getActiveRange()
and getValues()
method as a workaround would help.
To use this workaround you just need to highlight the range of the value
and it returns an array
as the value of the parameter
additionally using .toast()
to check the return values of the highlighted cells
.
function onOpen(e) {
SpreadsheetApp.getUi()
.createMenu('foo')
.addItem('bar', 'foobar')
.addToUi();
}
function foobar(bar = SpreadsheetApp.getActiveRange().getValues()) {
return SpreadsheetApp.getActiveSpreadsheet().toast(bar);
}
Reference: