excelvbascriptingoffice365office-scripts

Can VBA be used to generate a button that is assigned to an Office Script?


I'd like to know whether a VBA script can be used to create button shape that is then assigned to an Office Script, and if so, how?

I use VBA scripts to format and generate sheet layouts, formulas, and buttons assigned to other VBA scripts. There are a couple of other functions designed for data collection with a mobile tablet, so I've written a couple Office Scripts for that. The problem is that these sheets need to be re-generated periodically, and my VBA scripts wipe the sheet clean, including the Office Scripts button I put in manually. I could have my VBA scripts avoid deleting these shapes, but it'd be much better to be able to re-generate them along with everything else.

I have tried recording a VBA macro and manually creating the button shapes in Automate. Reviewing the script, the macro completely ignored recording actions that involved inserting an Office Scripts button.

Seems like this shouldn't be too difficult to accomplish, but I haven't been able to figure it out or find any resource online to help with this.

So, is this possible: can VBA be used to create a button shape and assign it to an Office Script?


Solution

  • No, that is not possible currently. The JavaScript API for MS Office doesn't provide anything for that. Note, you may create buttons and call COM add-ins instead.

    You can post or vote for an existing feature request on Tech Community where they are considered when the Office dev team go through the planning process. Post the product feature request at https://aka.ms/M365dev-suggestions .