Office Automation - Ribbon

I have been doing quite a lot with Office Automation. We now have a customer who is very interested in this work, but(!) :slight_smile: he wants to have a Ribbon Icon in his Office Word 2019 opening our programm. So basically an own Icon doing nothing else than calling our Xojo app. Is this possible within Xojo with the automation plugin?

I doubt it will and this brings me to my next problem … how can I realize this? I googled for quite a while, but it seems that his ribbon stuff isn’t easy … embedding xml into a .dotm template etc … I hope I’m getting it wrong. Any template code or a hint to a good online resource will be much appreciated. It is now my second morning waking up, and still having no clue how to realize this (silly) request. I think the customer just wants to see his nice logo in Word, as this is what they have been seeing for 2 decades in their Word environment :-).

For a full ribbon you are correct. But I remember that I cheated and added a simple menu to the ribbon. But I don’t have access to my code anymore. Have you studied the bible (https://www.amazon.com/-/de/Excel-2013-Power-Programming-VBA/dp/1118490398/ref=sr_1_1?__mk_de_DE=MŎ&dchild=1&keywords=walkenbach&qid=1590913937&sr=8-1)?

Can you create a ‘macro’, i.e. VBA code to launch your app. Customise the ribbon bar to add the macro to its own button. Change the image for the button to the logo/icon.

Possibly, but that would mean that I need to modify the ribbon on every client manually, or do I get it wrong?

One option you might explore is to automate Word using OLE when your app runs.
In theory you may be able to record yourself adding a toolbar button as a macro, then replay that using OLE or a vbscript file.

(I say in theory as I wasnt able to work out how to do that this morning, even manually and without recording a macro!)

No, as far as I remember recording doesn’t work for the ribbon. The code to add stuff to the ribbon was rather convoluted.

I had several Excel files that were distributed to users. At startup they registered themselves in the ribbon and on close they unregistered themselves.

You would have to customise each machines ribbon and add the VBA, but whilst doing a little research for this take a look here, which may assist. Not sure 100% it’s what you are after.

http://www.rondebruin.nl/win/s2/win001.htm

Thank you all. I found https://www.ribboncreator2019.de to be useful.

This will create a .dotm file, which will show the ribbon:

Within this dotm I can add some VBA so that the created button will run my xojo app

Dim PID as variant PID = Shell("pathToMyProgram", vbNormalFocus)

Now I only need to achieve that this dotm will open automatically when Word starts. Nonsense (and insecure) but customer is king …

Thank you. With the ribboncreator I can create a dotm file and put it on a network drive. Whoever will open this file, will then see the button in Word, but it will disappear, when the file is closed again. Which somehow makes sense, who wants to have permanently new ribbons created by default for Word :-).

Btw, more information on the Ribbon can be found here: VBA Ribbon - NotePad