Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Same sub in two modules, wrong one gets called?

I have two modules, production and testing. I have a menu bar with
buttons on it, which is populated in code like this:

Sub AddButton(barName As String, buttonName As String, commandName As
String)
Set newbutton = Application.CommandBars(barName).Controls.Add
(Type:=msoControlButton)
With newbutton
.OnAction = commandName
.Caption = buttonName
.Style = msoButtonCaption
.Visible = True
End With
End Sub

I am adding buttons to the bar like this:

Call AddButton("STAT", "Imply parameters", "testing.xla!Solve")

In spite of the name being fully qualified with the correct module
name, this button continues to call the version of Solve in
"production.xla". It's very annoying.

Any advice?

Maury
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Same sub in two modules, wrong one gets called?

Try this:

Application.CommandBars(barName).Reset

Then run your AddButton code again.


RBS


"Maury Markowitz" wrote in message
...
I have two modules, production and testing. I have a menu bar with
buttons on it, which is populated in code like this:

Sub AddButton(barName As String, buttonName As String, commandName As
String)
Set newbutton = Application.CommandBars(barName).Controls.Add
(Type:=msoControlButton)
With newbutton
.OnAction = commandName
.Caption = buttonName
.Style = msoButtonCaption
.Visible = True
End With
End Sub

I am adding buttons to the bar like this:

Call AddButton("STAT", "Imply parameters", "testing.xla!Solve")

In spite of the name being fully qualified with the correct module
name, this button continues to call the version of Solve in
"production.xla". It's very annoying.

Any advice?

Maury


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Same sub in two modules, wrong one gets called?

On Feb 19, 7:09*am, "RB Smissaert"
wrote:
Try this:

* Application.CommandBars(barName).Reset


Method "Reset" of object "CommandBar" failed.

What does the help mean when it says "Resets a built-in command bar to
its default configuration". What is the "default configuration"?

Maury
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
Stop VB from deleting modules from wrong file Code Numpty Excel Programming 3 February 5th 08 12:33 PM
Excel-called Dotnet DLL is using wrong Framework Tim Zych Excel Programming 1 November 23rd 07 07:33 PM
Public, Private, Event modules, Forms modules,,, Jim May Excel Programming 11 October 31st 05 03:12 AM
Basic question - modules and class modules - what's the difference? Mark Stephens[_3_] Excel Programming 9 May 8th 05 11:48 AM
Data form Dates wrong when called from macro? brym Excel Programming 0 July 29th 03 07:08 PM


All times are GMT +1. The time now is 04:42 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"