enuchi / React-Google-Apps-Script

This is your boilerplate project for developing React apps inside Google Sheets, Docs, Forms and Slides projects. It's perfect for personal projects and for publishing complex add-ons in the Google Workspace Marketplace.
MIT License
1.32k stars 171 forks source link

Can only add menu to 1 type of doc/slides/sheet ... ? #197

Closed sunshineo closed 1 year ago

sunshineo commented 1 year ago

I tried to have onOpen be like

export const onOpen = () => {
  try {
    const menu = DocumentApp.getUi()
      .createMenu('doc menu')
      .addItem('doc item', 'docFuction')

    menu.addToUi();
  }
  catch (e) {
  }

  try {
    const slidesMenu = SlidesApp.getUi()
      .createMenu('slides menu')
      .addItem('slides item', 'slidesFuction')

    slidesMenu.addToUi();
  }
  catch (e) {
  }
};

But this only worked for doc not slides. If I reverse the order, then it works for slides not doc. Can my app for both doc and slides?

enuchi commented 1 year ago

Not sure. I'd be surprised if it worked. Are you trying to have the same code work for both?

Does it throw an error, or in other words can you print e?

sunshineo commented 1 year ago

Yes, we want our add on to add menu to both Doc and Slides. (They also pretty much do the same thing of get some content and insert) And today I'm seeing this code is just working. I'm not sure if I saw it wrong yesterday or I'm seeing things now. Will report back. Thanks!

enuchi commented 1 year ago

OK sounds good. Let me know if resolved.

sunshineo commented 1 year ago

It's working. Thank you!