PC Review


Reply
Thread Tools Rate Thread

Assign Macro to a Menu Item using code

 
 
Steven
Guest
Posts: n/a
 
      13th Jun 2008
I have seen .OnAction such as:
Item2Sub2.OnAction = "ShowMessage"

but

How do I "Assign Macro" to a Menu Item in code?

Thank you,

Steven
 
Reply With Quote
 
 
 
 
Stephen Newman
Guest
Posts: n/a
 
      13th Jun 2008
This works for me.

With Application.CommandBars("Cell").Controls.Add(Temporary:=True)
.Caption = "Your Caption" 'Name the button
.OnAction = "YourModule.YourCode" 'Point to the code you want
to run
.FaceId = 1089 'Adds an icon
End With



On Thu, 12 Jun 2008 16:53:00 -0700, Steven
<(E-Mail Removed)> wrote:

>I have seen .OnAction such as:
>Item2Sub2.OnAction = "ShowMessage"
>
>but
>
>How do I "Assign Macro" to a Menu Item in code?
>
>Thank you,
>
>Steven

 
Reply With Quote
 
Steven
Guest
Posts: n/a
 
      13th Jun 2008
But it does not show up under the "Assign Macro" of the menu item. I want to
set it up to point to a macro in a different file just as if I had manually
gone to View / Toolbars / Customize and right clicked on the created Menu
Item and gone to "Assign Macro". I can attach a Macro from any file there
but I dont see how you do that from code.

"Stephen Newman" wrote:

> This works for me.
>
> With Application.CommandBars("Cell").Controls.Add(Temporary:=True)
> .Caption = "Your Caption" 'Name the button
> .OnAction = "YourModule.YourCode" 'Point to the code you want
> to run
> .FaceId = 1089 'Adds an icon
> End With
>
>
>
> On Thu, 12 Jun 2008 16:53:00 -0700, Steven
> <(E-Mail Removed)> wrote:
>
> >I have seen .OnAction such as:
> >Item2Sub2.OnAction = "ShowMessage"
> >
> >but
> >
> >How do I "Assign Macro" to a Menu Item in code?
> >
> >Thank you,
> >
> >Steven

>

 
Reply With Quote
 
Steven
Guest
Posts: n/a
 
      13th Jun 2008
My error:
on the .OnAction you can call a macro from another file just as if you did
it manually. The only difference is that you do not see the macro under the
"Assign Macro". WOW ... That just made my Friday !!!!!!

"Steven" wrote:

> But it does not show up under the "Assign Macro" of the menu item. I want to
> set it up to point to a macro in a different file just as if I had manually
> gone to View / Toolbars / Customize and right clicked on the created Menu
> Item and gone to "Assign Macro". I can attach a Macro from any file there
> but I dont see how you do that from code.
>
> "Stephen Newman" wrote:
>
> > This works for me.
> >
> > With Application.CommandBars("Cell").Controls.Add(Temporary:=True)
> > .Caption = "Your Caption" 'Name the button
> > .OnAction = "YourModule.YourCode" 'Point to the code you want
> > to run
> > .FaceId = 1089 'Adds an icon
> > End With
> >
> >
> >
> > On Thu, 12 Jun 2008 16:53:00 -0700, Steven
> > <(E-Mail Removed)> wrote:
> >
> > >I have seen .OnAction such as:
> > >Item2Sub2.OnAction = "ShowMessage"
> > >
> > >but
> > >
> > >How do I "Assign Macro" to a Menu Item in code?
> > >
> > >Thank you,
> > >
> > >Steven

> >

 
Reply With Quote
 
Stephen Newman
Guest
Posts: n/a
 
      13th Jun 2008
On Fri, 13 Jun 2008 08:14:05 -0700, Steven
<(E-Mail Removed)> wrote:

You're welcome.

>My error:
>on the .OnAction you can call a macro from another file just as if you did
>it manually. The only difference is that you do not see the macro under the
>"Assign Macro". WOW ... That just made my Friday !!!!!!
>
>"Steven" wrote:
>
>> But it does not show up under the "Assign Macro" of the menu item. I want to
>> set it up to point to a macro in a different file just as if I had manually
>> gone to View / Toolbars / Customize and right clicked on the created Menu
>> Item and gone to "Assign Macro". I can attach a Macro from any file there
>> but I dont see how you do that from code.
>>
>> "Stephen Newman" wrote:
>>
>> > This works for me.
>> >
>> > With Application.CommandBars("Cell").Controls.Add(Temporary:=True)
>> > .Caption = "Your Caption" 'Name the button
>> > .OnAction = "YourModule.YourCode" 'Point to the code you want
>> > to run
>> > .FaceId = 1089 'Adds an icon
>> > End With
>> >
>> >
>> >
>> > On Thu, 12 Jun 2008 16:53:00 -0700, Steven
>> > <(E-Mail Removed)> wrote:
>> >
>> > >I have seen .OnAction such as:
>> > >Item2Sub2.OnAction = "ShowMessage"
>> > >
>> > >but
>> > >
>> > >How do I "Assign Macro" to a Menu Item in code?
>> > >
>> > >Thank you,
>> > >
>> > >Steven
>> >

 
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
Add image to Context Menu Strip Menu Item in code Joe Cool Microsoft C# .NET 2 29th Jul 2009 02:16 AM
macro does not assign to menu? Robert24 Microsoft Excel Misc 2 2nd Oct 2008 04:39 AM
how do I assign a CTRL + shortcut key to a menu item (paste speci. PaulGB Microsoft Excel Misc 1 14th Jul 2008 03:19 AM
Assign macro to each item of a drop-down list or combo box - how? jbp20717 Microsoft Excel Programming 1 27th Jul 2005 11:17 AM
Can I assign a macro to each item in a drop-down list? jbp20717 Microsoft Excel Programming 5 4th Jul 2005 01:38 PM


Features
 

Advertising
 

Newsgroups
 


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