Excel 2007 Ribbon Check custom buttons

A

Alice

Hi all,

via xml i add a tab to a ribbon, say something like:

<tab id="myId1" lable="MyLable">
<group id="gr1">
<button id="myButton1" onAction="MySub1" lable="Test1">
<button id="myButton1" onAction="MySub1" lable="Test2">>
</group>
<group id="gr2">
<button id="myButton1" onAction="MySub2" lable="Test3">>
<button id="myButton1" onAction="MySub2" lable="Test4">>
</group>
</tab>

In my workbook i have now two subs

sub MySub1(control as IbRibbonControl)
'some action
end sub

sub MySub2(control as IbRibbonControl)
'some action
end sub

Now it could be possible, that sombody removes the xmlpart for group gr2.

How can i check in my Sub MySub1 if the group gr2 with the buttons with the
given id and onAction arguments exists?

Is there a way? I found only GetMso ... which won't help with own
definitions?

Any idea?

tx in advance
Alice
 
M

michael.beckinsale

Hi all,

via xml i add a tab to a ribbon, say something like:

<tab id="myId1" lable="MyLable">
<group id="gr1">
<button id="myButton1" onAction="MySub1" lable="Test1">
<button id="myButton1" onAction="MySub1" lable="Test2">>
</group>
<group id="gr2">
<button id="myButton1" onAction="MySub2" lable="Test3">>
<button id="myButton1" onAction="MySub2" lable="Test4">>
</group>
</tab>

In my workbook i have now two subs

sub MySub1(control as IbRibbonControl)
'some action
end sub

sub MySub2(control as IbRibbonControl)
'some action
end sub

Now it could be possible, that sombody removes the xmlpart for group gr2.

How can i check in my Sub MySub1 if the group gr2 with the buttons with the
given id and onAction arguments exists?

Is there a way? I found only GetMso ... which won't help with own
definitions?

Any idea?

tx in advance
Alice

Alice,

If somebody has 'removed' the XML part then the group/buttons wont be
on the ribbon to trigger the macro so a check wont be necessary.

Or am l missing something?

Regards

Michael Beckinsale
 
A

Alice

michael.beckinsale said:
Alice,

If somebody has 'removed' the XML part then the group/buttons wont be
on the ribbon to trigger the macro so a check wont be necessary.

Or am l missing something?

Regards

Michael Beckinsale
Hi Michael,
say you develop an add-in and you want to have a group with links to your
homepage or something like that.
Now if somebody removes this group you want to display a message in the
other procedure, that it is not the original add-in and exit the code.
Thats the reason behind.
Regards
 
J

Jim Rech

Lets say that you add a callback attribute to the button you want to know
exists like:

getVisible="MySpecialGetVisibleCall"

When the ribbon is created by Excel that sub will be called. It can then set
a public variable "IAmHere" to True.

If the button exists IAmHere will be True; if it does not the callback will
never be called so IAmHere will be False.

Of course sub MySpecialGetVisibleCall should set the return value to true.
 
A

Alice

Hi Jim,
tx for this idea. Just simple as that.
I played a little bit arround, getVisible didn't liked me but getScreentip
worked fine.
It's not over yet, because still a unfriendly person could leave in the
button, just rename it an kicks away the onAction.
(Ok i can set the lable with a callback - but the Action?)
And i just couldn't figure out, how to get the onAction Argument back.

In former commandbar handling you could retrieve the onAction arguments,
here i don't know how.

This ribbon is in a few ways not easy to handle and not much information in
the help :-(

But thanks anyway an perhaps you have some more ideas.

Regards
 
J

Jim Rech

Well I guess you're right if someone can edit your RibbonX ultimately there
is nothing you can do about it. Such a person could edit your VBA too since
even a protected project can be broken into.

As a developer I try to make it hard for users to accidentally screw up my
application. But I don't worry about someone deliberately doing so. I
can't stop them and they know they're doing it so they are on their own.
 
A

Alice

Hi Jim,
i know, that people are able to break up vba codeprotection :)
But i find it much easier for people to destroy customUI than handling an
hexeditor ;-)
But you'e right anyway. Normaly i use a dll for critical vba code.

But still i don't like it, that i can't prove the existenz of a ribbon part
and it's onAction.

Regards and tx again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top