Google Apps Scripts

The onOpen() function is automatically executed when the document is opened:

https://developers.google.com/apps-script/guides/triggers/#onopen

Create a new menu:

https://developers.google.com/apps-script/reference/base/ui#createMenu(caption)