Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Pass Command Button info

I have a custom menu on my sheet. Each menu option's name contains the name
of the sheet I want to interact with. What I want to do is when the user
clicks the menu item I want to pass either the name of the menu item clicked
or pass an object referring to the menu button, so I can write one method
rather than 12 to control the menu. is this possible in VBA?

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Pass Command Button info

The

Application.CommandBars.ActionControl

returns a CommandBarButton object referencing the button that called the
assigned procedure. So if you have several buttons assigned to the same
procedure, this object will tell you what button called it. You can then get
the Caption of the control to see what see it needs to work with.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)'



"J Streger" wrote in message
...
I have a custom menu on my sheet. Each menu option's name contains the name
of the sheet I want to interact with. What I want to do is when the user
clicks the menu item I want to pass either the name of the menu item
clicked
or pass an object referring to the menu button, so I can write one method
rather than 12 to control the menu. is this possible in VBA?

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Pass Command Button info

Thank you Chip. Worked like a charm.

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003



"Chip Pearson" wrote:

The

Application.CommandBars.ActionControl

returns a CommandBarButton object referencing the button that called the
assigned procedure. So if you have several buttons assigned to the same
procedure, this object will tell you what button called it. You can then get
the Caption of the control to see what see it needs to work with.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)'



"J Streger" wrote in message
...
I have a custom menu on my sheet. Each menu option's name contains the name
of the sheet I want to interact with. What I want to do is when the user
clicks the menu item I want to pass either the name of the menu item
clicked
or pass an object referring to the menu button, so I can write one method
rather than 12 to control the menu. is this possible in VBA?

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default Pass Command Button info

I used a loop to setup the names of each button representing the name of each
sheet in my workbook. Basically if the user clicked on the button, it would
take them to that page (very simple). I couldnt figure out how to get the
sheet name they wanted (ie. the caption of the button). I set a tag value to
the button and it worked great.

Dim pg as String
pg = CommandBars.ActionControl.Tag 'pg is the name of the sheet user wants
to switch to.

"Chip Pearson" wrote:

The

Application.CommandBars.ActionControl

returns a CommandBarButton object referencing the button that called the
assigned procedure. So if you have several buttons assigned to the same
procedure, this object will tell you what button called it. You can then get
the Caption of the control to see what see it needs to work with.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)'



"J Streger" wrote in message
...
I have a custom menu on my sheet. Each menu option's name contains the name
of the sheet I want to interact with. What I want to do is when the user
clicks the menu item I want to pass either the name of the menu item
clicked
or pass an object referring to the menu button, so I can write one method
rather than 12 to control the menu. is this possible in VBA?

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Button Info FIRSTROUNDKO via OfficeKB.com Excel Discussion (Misc queries) 2 September 4th 07 05:22 PM
Pass Defined Name to a Command Button Connie Excel Programming 3 October 10th 06 07:45 AM
Pass a cell in sheet to macro or command button Connie Excel Programming 2 October 8th 06 04:54 PM
Pass Info Between Macros (Re-Visited) Rob Excel Programming 4 August 31st 06 07:57 PM
Make more info appear when mouse moves over a macro command button Jeff at Bosch Corp. Excel Programming 1 May 25th 05 09:44 PM


All times are GMT +1. The time now is 06:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"