PC Review


Reply
Thread Tools Rate Thread

Determine which commandbar called a function

 
 
Sgt Waddle
Guest
Posts: n/a
 
      21st Oct 2008
Hello,

I have been using the following function to change the faceid on a
commandbar button once it has been clicked:

Function ChangeFace()
Dim OldCTRL

Set OldCTRL =
CommandBars("SHOW").Controls(CommandBars.ActionControl.Caption)

OldCTRL.FaceId = 1087

OldCTRL.Style = msoButtonIconAndCaptionBelow
End Function

The function is called when each button is clicked.

the line Set OldCTRL = CommandBars("SHOW").Controls
CommandBars.ActionControl.Caption) sets which button on the commandbar named
SHOW called the function.

I would like to be able to capture which commandbar and which button called
the function so I can use the same function from different commandbars.

Something like (pseudo code)
Set OldCTRL =
CommandBars(ActiveCommandBar).Controls(CommandBars.ActionControl.Caption)

Any help is greatly appreciated,
Kevin



 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      21st Oct 2008
Just use...
Set OldCtrl = Application.CommandBars.ActionControl
And...
OldCtrl.Parent will return the controls location, but there is no need for this in the situation you describe.
--
Jim Cone
Portland, Oregon USA



"Sgt Waddle"
wrote in message
Hello,
I have been using the following function to change the faceid on a
commandbar button once it has been clicked:

Function ChangeFace()
Dim OldCTRL
Set OldCTRL =
CommandBars("SHOW").Controls(CommandBars.ActionControl.Caption)
OldCTRL.FaceId = 1087
OldCTRL.Style = msoButtonIconAndCaptionBelow
End Function

The function is called when each button is clicked.
the line Set OldCTRL = CommandBars("SHOW").Controls
CommandBars.ActionControl.Caption) sets which button on the commandbar named
SHOW called the function.
I would like to be able to capture which commandbar and which button called
the function so I can use the same function from different commandbars.
Something like (pseudo code)
Set OldCTRL =
CommandBars(ActiveCommandBar).Controls(CommandBars.ActionControl.Caption)

Any help is greatly appreciated,
Kevin



 
Reply With Quote
 
Sqt Waddle
Guest
Posts: n/a
 
      21st Oct 2008
A little Google and 'Bob's your uncle!'

I did not need to name the CommandBar

Function ChangeFace()
Application.CommandBars.ActionControl.Style = msoButtonIconAndCaptionBelow
Application.CommandBars.ActionControl.FaceId = 1087
End Function

Thanks!

"Sgt Waddle" wrote:

> Hello,
>
> I have been using the following function to change the faceid on a
> commandbar button once it has been clicked:
>
> Function ChangeFace()
> Dim OldCTRL
>
> Set OldCTRL =
> CommandBars("SHOW").Controls(CommandBars.ActionControl.Caption)
>
> OldCTRL.FaceId = 1087
>
> OldCTRL.Style = msoButtonIconAndCaptionBelow
> End Function
>
> The function is called when each button is clicked.
>
> the line Set OldCTRL = CommandBars("SHOW").Controls
> CommandBars.ActionControl.Caption) sets which button on the commandbar named
> SHOW called the function.
>
> I would like to be able to capture which commandbar and which button called
> the function so I can use the same function from different commandbars.
>
> Something like (pseudo code)
> Set OldCTRL =
> CommandBars(ActiveCommandBar).Controls(CommandBars.ActionControl.Caption)
>
> Any help is greatly appreciated,
> Kevin
>
>
>

 
Reply With Quote
 
Sqt Waddle
Guest
Posts: n/a
 
      21st Oct 2008
Jim,

I didn't see your reply until after I solved it.

Thanks for taking the time to reply.
Kevin

"Jim Cone" wrote:

> Just use...
> Set OldCtrl = Application.CommandBars.ActionControl
> And...
> OldCtrl.Parent will return the controls location, but there is no need for this in the situation you describe.
> --
> Jim Cone
> Portland, Oregon USA
>
>
>
> "Sgt Waddle"
> wrote in message
> Hello,
> I have been using the following function to change the faceid on a
> commandbar button once it has been clicked:
>
> Function ChangeFace()
> Dim OldCTRL
> Set OldCTRL =
> CommandBars("SHOW").Controls(CommandBars.ActionControl.Caption)
> OldCTRL.FaceId = 1087
> OldCTRL.Style = msoButtonIconAndCaptionBelow
> End Function
>
> The function is called when each button is clicked.
> the line Set OldCTRL = CommandBars("SHOW").Controls
> CommandBars.ActionControl.Caption) sets which button on the commandbar named
> SHOW called the function.
> I would like to be able to capture which commandbar and which button called
> the function so I can use the same function from different commandbars.
> Something like (pseudo code)
> Set OldCTRL =
> CommandBars(ActiveCommandBar).Controls(CommandBars.ActionControl.Caption)
>
> Any help is greatly appreciated,
> Kevin
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I determine the control that called a sub? Academia Microsoft C# .NET 2 24th Feb 2008 02:41 PM
how to combine an IF Function with a lookup function to determine =?Utf-8?B?Y2F0aDYzQHByaW11cy5jb20uYXU=?= Microsoft Excel Worksheet Functions 1 5th Dec 2006 06:09 AM
CommandBar function call w/o parens runs function 2-3 times Mark Hammer Microsoft Access Form Coding 0 1st Jan 2004 04:53 AM
Save Event - Determine if called by code or user David Sedberry Microsoft Excel Programming 0 2nd Oct 2003 04:56 PM
How could the IRR function be called in C# Burton Wilkins Microsoft Dot NET Framework 0 25th Sep 2003 11:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:49 AM.