Identify which Button of which User defined CommandBar was clicked

MY-Rudy

New Member
Joined
Sep 26, 2011
Messages
2
Hi, I am using an Excel File which was generated under Office97 and is running with Office10 without problems. Every newer version Office11 and later the file is not working.

Basic Problem: the file contains two user defined CommandBars "Calculation Toolbar" and "Edit Toolbar". The Application.Caller function is used to identify the button and the name of the toolbar.

BtnIndex = Application.Caller(1) 'returns button number on toolbar
ToolBar = Application.Caller(2) 'returns name of the toolbar

The new office version returns the correct number for the BtnIndex but for the ToolBar variable I only receive a number as string. I could not find a correlation between this number Application.Caller(2) deliveres and the needed name of the calling CommandBar.

Is there another function I can use to identify the name of the toolbar where the button is located is clicked?

Thanks in advance.

Rudy
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
...ok, I found the solution:

BtnIndex = Application.CommandBars.ActionControl.Index
ToolBar = Application.CommandBars.ActionControl.Parent.Name

so instead of using the Application.Caller function the ActionControl can do.

Perhaps this is useful for people with a similiar problem.

Thanks.

Rudy.
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,487
Members
452,917
Latest member
MrsMSalt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top