Just dropping a link, answered here:
If you want this done with a button, call the script that’s shown on button click, either instead or in addition to.