The
CommandBars
object is a deprecated way to modify the UI (mostly/exlusively? the menu bar). In
Office versions later than 2003, added menu entries appear under the Add-ins tab)
PowerShell: Iterating over commands in CommandBars
$xls = get-activeObject excel.application
$cmdBars = $xls.VBE.CommandBars
foreach ($cmdBar in $cmdBars){
$cmdBar.name
foreach ($control in $cmdBar.controls) {
" - $($control.caption) ($($control.id))";
}
}
Later…
$cmdBarDebug = $cmdBars.item("Debug")
$compile = $cmdBars.FindControl(1, 578)
$compile.execute()
}