Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default commandbar control and application.caller

I'm trying to write a CommandbarButton OnAction sub that uses
Application.Caller to toggle the state of the button that called it, even if
it's down a couple levels of submenus.

So if I have a toolbar called "toolbar" and a button called "button" that's
in a submenu I'd like to have the .OnAction of "button" be "toggle_button".
Since, as far as I can tell, an onaction macro doesn't take arguments (can
it?), I'd hard-code "toolbar" in the macro and use (I guess)
application.caller to identify the control.
I've tried a few things: "application.parent" isn't valid, unfortunately, or
I could work my way back up through the menus. I've struggled with a
recursive function and a bunch of nested loops, but it's ugly, and I'm
hoping maybe somebody already has a good solution for this.

Does that make any sense? Of course, I don't really care if the solution
involves application.caller or not.

Thanks in advance,

Doug


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default commandbar control and application.caller

Doug,

Here is one way. This checks whether the button is depressed or not and
reverses it. You would add your code as required.

Sub myMacro()
With Application.CommandBars.ActionControl
If .State = msoButtonUp Then
'do one thing
.State = msoButtonDown
Else
'do something else
.State = msoButtonUp
End If
End With

End Sub

You can also pass parameters to OnACtion like so

sAction = "'PERSONAL.XLS'!'PasteComments ""Bob"'"
.OnACtion = sACtion

or you could set the Parameter property and test that in
Application.CommandBars.ActionControl

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Doug Glancy" wrote in message
...
I'm trying to write a CommandbarButton OnAction sub that uses
Application.Caller to toggle the state of the button that called it, even

if
it's down a couple levels of submenus.

So if I have a toolbar called "toolbar" and a button called "button"

that's
in a submenu I'd like to have the .OnAction of "button" be

"toggle_button".
Since, as far as I can tell, an onaction macro doesn't take arguments (can
it?), I'd hard-code "toolbar" in the macro and use (I guess)
application.caller to identify the control.
I've tried a few things: "application.parent" isn't valid, unfortunately,

or
I could work my way back up through the menus. I've struggled with a
recursive function and a bunch of nested loops, but it's ugly, and I'm
hoping maybe somebody already has a good solution for this.

Does that make any sense? Of course, I don't really care if the solution
involves application.caller or not.

Thanks in advance,

Doug




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default commandbar control and application.caller

Bob,

Wonderful. Now why didn't I just ask these questions at ten o:clock last
night, instead of tying my brain in knots?

Thanks a bunch,

Doug

"Bob Phillips" wrote in message
...
Doug,

Here is one way. This checks whether the button is depressed or not and
reverses it. You would add your code as required.

Sub myMacro()
With Application.CommandBars.ActionControl
If .State = msoButtonUp Then
'do one thing
.State = msoButtonDown
Else
'do something else
.State = msoButtonUp
End If
End With

End Sub

You can also pass parameters to OnACtion like so

sAction = "'PERSONAL.XLS'!'PasteComments ""Bob"'"
.OnACtion = sACtion

or you could set the Parameter property and test that in
Application.CommandBars.ActionControl

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Doug Glancy" wrote in message
...
I'm trying to write a CommandbarButton OnAction sub that uses
Application.Caller to toggle the state of the button that called it,

even
if
it's down a couple levels of submenus.

So if I have a toolbar called "toolbar" and a button called "button"

that's
in a submenu I'd like to have the .OnAction of "button" be

"toggle_button".
Since, as far as I can tell, an onaction macro doesn't take arguments

(can
it?), I'd hard-code "toolbar" in the macro and use (I guess)
application.caller to identify the control.
I've tried a few things: "application.parent" isn't valid,

unfortunately,
or
I could work my way back up through the menus. I've struggled with a
recursive function and a bunch of nested loops, but it's ugly, and I'm
hoping maybe somebody already has a good solution for this.

Does that make any sense? Of course, I don't really care if the

solution
involves application.caller or not.

Thanks in advance,

Doug






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default commandbar control and application.caller

Doug,

That's why we are here. Glad it helped.

Bob

"Doug Glancy" wrote in message
...
Bob,

Wonderful. Now why didn't I just ask these questions at ten o:clock last
night, instead of tying my brain in knots?

Thanks a bunch,

Doug

"Bob Phillips" wrote in message
...
Doug,

Here is one way. This checks whether the button is depressed or not and
reverses it. You would add your code as required.

Sub myMacro()
With Application.CommandBars.ActionControl
If .State = msoButtonUp Then
'do one thing
.State = msoButtonDown
Else
'do something else
.State = msoButtonUp
End If
End With

End Sub

You can also pass parameters to OnACtion like so

sAction = "'PERSONAL.XLS'!'PasteComments ""Bob"'"
.OnACtion = sACtion

or you could set the Parameter property and test that in
Application.CommandBars.ActionControl

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Doug Glancy" wrote in message
...
I'm trying to write a CommandbarButton OnAction sub that uses
Application.Caller to toggle the state of the button that called it,

even
if
it's down a couple levels of submenus.

So if I have a toolbar called "toolbar" and a button called "button"

that's
in a submenu I'd like to have the .OnAction of "button" be

"toggle_button".
Since, as far as I can tell, an onaction macro doesn't take arguments

(can
it?), I'd hard-code "toolbar" in the macro and use (I guess)
application.caller to identify the control.
I've tried a few things: "application.parent" isn't valid,

unfortunately,
or
I could work my way back up through the menus. I've struggled with a
recursive function and a bunch of nested loops, but it's ugly, and I'm
hoping maybe somebody already has a good solution for this.

Does that make any sense? Of course, I don't really care if the

solution
involves application.caller or not.

Thanks in advance,

Doug








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
Application.Caller Marcelo Excel Discussion (Misc queries) 6 June 23rd 06 03:07 PM
Row = Application.Caller.Row Charles Woll Excel Worksheet Functions 8 February 28th 05 02:04 PM
Application.Caller Mark Worthington Excel Programming 9 February 12th 04 07:32 PM
Application.caller Clark B Excel Programming 2 July 29th 03 11:17 PM
DDE and application.caller help Ross Kaminsky Excel Programming 1 July 17th 03 04:17 PM


All times are GMT +1. The time now is 12:09 AM.

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

About Us

"It's about Microsoft Excel"