Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Can you check the coding here please?

Try this:

With Application.CommandBars("Standard")
.Controls(ID:=2950)
.OnAction = "myMacro"
End With

Regards,
Rob



Richard wrote:
Hello,

I'm trying to assgin a macro on existing menu (that I added previousely) in
command bar as below, but I 'm getting a error. By the way, ID:2950 is the
Smiley face icon.

Can anyone help me to fix it, please?

Error msg is "name or argument not found"

With Application.CommandBars("Standard").Controls(ID:=2 950)
.OnAction = "myMacro"
End With


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Can you check the coding here please?

Sorry, I got carried away... Reference your button's index, not it's
ID.
Example, If I have one button on the menu bar, it's index is 1. If I
have 3 buttons, then the index is it's position on the bar counting
from the left.

With Application.CommandBars("Standard").Controls(Your Button index)
.OnAction = "ThisWorkbook.myMacro"
End With



OKROB wrote:
Try this:

With Application.CommandBars("Standard")
.Controls(ID:=2950)
.OnAction = "myMacro"
End With

Regards,
Rob



Richard wrote:
Hello,

I'm trying to assgin a macro on existing menu (that I added previousely) in
command bar as below, but I 'm getting a error. By the way, ID:2950 is the
Smiley face icon.

Can anyone help me to fix it, please?

Error msg is "name or argument not found"

With Application.CommandBars("Standard").Controls(ID:=2 950)
.OnAction = "myMacro"
End With


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Can you check the coding here please?

ok, first things first... Are you just wanting to CHANGE a button, or
are you adding a button?
If you want to change an existing button, the button's position will
give you the reference number. Like I said, it's numbered from left to
right on the command bar.

With Application.CommandBars("Standard").Controls(ID:=2 950)
.OnAction = "myMacro"
End With


Basically what the error when the code above is run is telling you that
you haven't told it which button to set the the macro to.
You need to reference the button, by either the index number (if the
button exists) or when you create the button like this:

With
Application.CommandBars("Standard").Controls.Add(T ype:=msoControlButton)

.FaceId = 2950
.OnAction = "myMacro"
End With



Richard wrote:
OKROB,

How can I find the index number?

As you can see beow note, I added the icon by coding below.

With Application.CommandBars("Standard").Controls.Add( _
Type:=msoControlButton, _
ID:=2950, Befo=9)
End With

"OKROB" wrote:

Sorry, I got carried away... Reference your button's index, not it's
ID.
Example, If I have one button on the menu bar, it's index is 1. If I
have 3 buttons, then the index is it's position on the bar counting
from the left.

With Application.CommandBars("Standard").Controls(Your Button index)
.OnAction = "ThisWorkbook.myMacro"
End With



OKROB wrote:
Try this:

With Application.CommandBars("Standard")
.Controls(ID:=2950)
.OnAction = "myMacro"
End With

Regards,
Rob



Richard wrote:
Hello,

I'm trying to assgin a macro on existing menu (that I added previousely) in
command bar as below, but I 'm getting a error. By the way, ID:2950 is the
Smiley face icon.

Can anyone help me to fix it, please?

Error msg is "name or argument not found"

With Application.CommandBars("Standard").Controls(ID:=2 950)
.OnAction = "myMacro"
End With




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Can you check the coding here please?

I ran the code and it works. Can you tell me if you are trying to edit
a button's function, or if you are adding a button to the "Standard"
toolbar. Perhaps that will clarify the issue.
Rob

Richard wrote:
OKROB,

I don't see any difference in your code from my code and I'm getting same
error.

Thanks

"OKROB" wrote:

Try this:

With Application.CommandBars("Standard")
.Controls(ID:=2950)
.OnAction = "myMacro"
End With

Regards,
Rob



Richard wrote:
Hello,

I'm trying to assgin a macro on existing menu (that I added previousely) in
command bar as below, but I 'm getting a error. By the way, ID:2950 is the
Smiley face icon.

Can anyone help me to fix it, please?

Error msg is "name or argument not found"

With Application.CommandBars("Standard").Controls(ID:=2 950)
.OnAction = "myMacro"
End With




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
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM
Need help with check box coding, urgent!!! inbound03[_10_] Excel Programming 0 January 6th 04 06:47 PM
Need help with check box coding, urgent!!! inbound03[_9_] Excel Programming 0 January 6th 04 06:29 PM
Coding to check for a sheet name and add it if it's not there AlanN Excel Programming 2 August 21st 03 09:17 PM


All times are GMT +1. The time now is 02:25 PM.

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"