XML Ribbon run AddIn

Started by Sebastian, December 02, 2014, 10:41:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sebastian

Hello Visio Guys,

I want to start a VSL AddIn function with an xml ribbon button. I assigned the statement:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="customTab" label="Custom Tab">
<group id="customGroup" label="Custom Group">
<button id="customButton1" label="Custom Button1" imageMso="HappyFace" size="large" onAction="=RUNADDON('Shapes verschieben...')" />
<button id="customButton2" label="Custom Button2" imageMso="HappyFace" size="large" onAction="Shapes verschieben..." />
<button id="customButton3" label="Custom Button3" imageMso="HappyFace" size="large" onAction="RUNADDON('Shapes verschieben...')" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>

to the CustomUI property of the ActiveDocument object. But I can't figure out how to call the AddIn function.
What code or calls can be put behind onAction (except VBA functions)?

Cheers
Sebastian

Maybe I should add that I can't use IDispatcher and normal Callback stuff because of some incompatibility of my VSL to the Microsoft tool chain (refer: http://visguy.com/vgforum/index.php?topic=6070.0).

Attached you can find an example. The XML is added with OfficeCustomUIEditor http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/08/07/7293.aspx.

Nikolay

#1
Hi Sebastian,

As far as I know, you'll need to implement IDispatch/IRibbonExtensibility to add a ribbon to the VSL. What kind of incompatibility are you talking about?

Here is a brief description from Barry how to make a VSL with Ribbon:
http://visguy.com/vgforum/index.php?topic=1168.msg5047#msg5047

A little bit old, but I think it is still valid.
The callbacks are supposed to be implemented in the same object you pass as the first parameter to the RegisterRibbonX

IDispatch implementation may be a bit messy; do you use ATL in your project (which language/environment do you use to build the VSL)?

Sebastian

Hi Nikolay,

I am not sure if my beer fund can handle your support :D...

I use Delphi XE3 with an import of the visio tlb and a framework from 1999 http://www.grahamwideman.com/gw/tech/Visio/delphi/index.htm. The framework can handle Visio events but has no implementation for ribbon IDispatch stuff. I found a CPP implementation in the Visio2013SDK (FlowSampleRibbonX.cpp), but as you say it's a bit messy.

Is there no chance to call a public function in onAction? I found something similar for Access Ribbons http://www.access-im-unternehmen.de/631.0.html.

Cheers
Sebastian

Nikolay

Yep, that's what I mean by messy  ;D

As far as I know, you can call only VBA code  from the ribbon installed with Document.CustomUI, not addons.

Basically this is what you need to do in a VSL (but I don't know how to do it in Delphi):

1. Create a COM object which implements IDispatch and IRibbonExtensibility.
2. Pass that object as first parameter to the RegisterRibbonX on Addon's loading.
3. In your COM object implementation, create functions to react to the button clicks. In ribbon, you write the names of those in onAction, and Visio calls them by name (using IDispatch) when user clicks a button.