ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   OnAction command failure (https://www.excelbanter.com/excel-programming/282872-onaction-command-failure.html)

[email protected]

OnAction command failure
 
I use Excel 2000. My problem is that the following code
works only on my computer. I have tested the same code
on five different Excel 2000 computers but it works only
for me. The Toolsoptions, ToolsVBA project properties,
toolsdigital signature and toolsreferences
settings are the same for all (five) computers.
Any help is most appreciated.

Sub DropDownMenu5()
Set NewMenu = MenuBars(xlWorksheet).Menus.Add
(Caption:="ID Filter", Befo="Help")
Set MenuItemAdded = MenuBars(xlWorksheet).Menus("ID
Filter").MenuItems.Add(Caption:="1",
OnAction:="'DataFiltera 1'")
Set MenuItemAdded = MenuBars(xlWorksheet).Menus("ID
Filter").MenuItems.Add(Caption:="2",
OnAction:="'DataFiltera 2'")
End Sub

Sub DataFiltera(Kriteria As Integer)
Select Case Kriteria
Case 1
Sheets("Sheet1").Range("A2") = "value 1"
Case 2
Sheets("Sheet1").Range("A2") = "value 2"
End Select
End Sub


Paul D[_2_]

OnAction command failure
 
can you be more specific about what does not work? Error messages received?
etc.
Paul

" wrote in
message ...
I use Excel 2000. My problem is that the following code
works only on my computer. I have tested the same code
on five different Excel 2000 computers but it works only
for me. The Toolsoptions, ToolsVBA project properties,
toolsdigital signature and toolsreferences
settings are the same for all (five) computers.
Any help is most appreciated.

Sub DropDownMenu5()
Set NewMenu = MenuBars(xlWorksheet).Menus.Add
(Caption:="ID Filter", Befo="Help")
Set MenuItemAdded = MenuBars(xlWorksheet).Menus("ID
Filter").MenuItems.Add(Caption:="1",
OnAction:="'DataFiltera 1'")
Set MenuItemAdded = MenuBars(xlWorksheet).Menus("ID
Filter").MenuItems.Add(Caption:="2",
OnAction:="'DataFiltera 2'")
End Sub

Sub DataFiltera(Kriteria As Integer)
Select Case Kriteria
Case 1
Sheets("Sheet1").Range("A2") = "value 1"
Case 2
Sheets("Sheet1").Range("A2") = "value 2"
End Select
End Sub




Tom Ogilvy

OnAction command failure
 
Suspect the other 5 computers have the lastest service release for xl2000.
I believe the lack of support for the undocumented feature of setting an
argument in an onaction string began in the lastest SR for xl2000.

--
Regards,
Tom Ogilvy


" wrote in
message ...
I use Excel 2000. My problem is that the following code
works only on my computer. I have tested the same code
on five different Excel 2000 computers but it works only
for me. The Toolsoptions, ToolsVBA project properties,
toolsdigital signature and toolsreferences
settings are the same for all (five) computers.
Any help is most appreciated.

Sub DropDownMenu5()
Set NewMenu = MenuBars(xlWorksheet).Menus.Add
(Caption:="ID Filter", Befo="Help")
Set MenuItemAdded = MenuBars(xlWorksheet).Menus("ID
Filter").MenuItems.Add(Caption:="1",
OnAction:="'DataFiltera 1'")
Set MenuItemAdded = MenuBars(xlWorksheet).Menus("ID
Filter").MenuItems.Add(Caption:="2",
OnAction:="'DataFiltera 2'")
End Sub

Sub DataFiltera(Kriteria As Integer)
Select Case Kriteria
Case 1
Sheets("Sheet1").Range("A2") = "value 1"
Case 2
Sheets("Sheet1").Range("A2") = "value 2"
End Select
End Sub




Tom Ogilvy

OnAction command failure
 
It fails when he presses the menu button because of this:

OnAction:="'DataFiltera 2'"

--
Regards,
Tom Ogilvy

"Paul D" wrote in message
...
can you be more specific about what does not work? Error messages

received?
etc.
Paul

" wrote

in
message ...
I use Excel 2000. My problem is that the following code
works only on my computer. I have tested the same code
on five different Excel 2000 computers but it works only
for me. The Toolsoptions, ToolsVBA project properties,
toolsdigital signature and toolsreferences
settings are the same for all (five) computers.
Any help is most appreciated.

Sub DropDownMenu5()
Set NewMenu = MenuBars(xlWorksheet).Menus.Add
(Caption:="ID Filter", Befo="Help")
Set MenuItemAdded = MenuBars(xlWorksheet).Menus("ID
Filter").MenuItems.Add(Caption:="1",
OnAction:="'DataFiltera 1'")
Set MenuItemAdded = MenuBars(xlWorksheet).Menus("ID
Filter").MenuItems.Add(Caption:="2",
OnAction:="'DataFiltera 2'")
End Sub

Sub DataFiltera(Kriteria As Integer)
Select Case Kriteria
Case 1
Sheets("Sheet1").Range("A2") = "value 1"
Case 2
Sheets("Sheet1").Range("A2") = "value 2"
End Select
End Sub






Jake Marx[_3_]

OnAction command failure
 
Hi Peter,

As Tom noted, passing arguments via the OnAction property is not fully
supported. Instead of using a parameter in your Subroutine, you can use the
Parameter property of the CommandBarButton. You can get this property from
within the DataFiltera subroutine with:

Application.CommandBars.ActionControl.Parameter

But in order to do this, you'll have to switch to using CommandBars instead
of Menus. Here's (what should be) a working example:

Sub DropDownMenu5()
Dim nHelp As Integer

nHelp = Application.CommandBars(1).Controls("Help").Index
With Application.CommandBars(1).Controls.Add( _
Type:=msoControlPopup, befo=nHelp, temporary:=True)
.Caption = "ID Filter"
With .Controls.Add(Type:=msoControlButton, _
temporary:=True)
.Caption = "1"
.OnAction = "DataFiltera"
.Parameter = "1"
End With
With .Controls.Add(Type:=msoControlButton, _
temporary:=True)
.Caption = "2"
.OnAction = "DataFiltera"
.Parameter = "2"
End With
End With
End Sub

Sub DataFiltera()
Dim Kriteria As Integer

Kriteria = CInt(Application.CommandBars.ActionControl.Paramet er)

Select Case Kriteria
Case 1
Sheets("Sheet1").Range("A2") = "value 1"
Case 2
Sheets("Sheet1").Range("A2") = "value 2"
End Select
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


wrote:
I use Excel 2000. My problem is that the following code
works only on my computer. I have tested the same code
on five different Excel 2000 computers but it works only
for me. The Toolsoptions, ToolsVBA project properties,
toolsdigital signature and toolsreferences
settings are the same for all (five) computers.
Any help is most appreciated.

Sub DropDownMenu5()
Set NewMenu = MenuBars(xlWorksheet).Menus.Add
(Caption:="ID Filter", Befo="Help")
Set MenuItemAdded = MenuBars(xlWorksheet).Menus("ID
Filter").MenuItems.Add(Caption:="1",
OnAction:="'DataFiltera 1'")
Set MenuItemAdded = MenuBars(xlWorksheet).Menus("ID
Filter").MenuItems.Add(Caption:="2",
OnAction:="'DataFiltera 2'")
End Sub

Sub DataFiltera(Kriteria As Integer)
Select Case Kriteria
Case 1
Sheets("Sheet1").Range("A2") = "value 1"
Case 2
Sheets("Sheet1").Range("A2") = "value 2"
End Select
End Sub




All times are GMT +1. The time now is 01:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com