Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Syntax problem in defining OnAction macro definition held in Add-in!

Hi. I am using a modified version of John Walkenbach's outstanding
MenuMaker.xls to create a table driven Command bar structure.

(1) However the lookup table instead of being in the ActiveworkBook,
is in an add-in, in a worksheet, "Menusheet" in C1menus.xla, and the
cells in column 3 of this sheet each hold the names of the OnAction
macros.

(2) These macros however, which the menu items call, continue to be in
the ActiveworkBook, but when the menu item is invoked we get an error
message "The macro C1menus.xla!FixAll" cannot be found".

John Walkenbach's MenuMaker.xls code, slightly modified, in the add-in
is as follows:

Dim PositionOrMacro

Set MenuSheet = ThisWorkbook.Sheets("Menusheet") 'Location for menu
data
' Make sure the menus aren't duplicated
Call DeleteMenu
' Initialize the row counter
Row = 4
' Add the menus, menu items and submenu items using data stored on
MenuSheet

Do Until IsEmpty(MenuSheet.Cells(Row, 1)) 'stop when column 1 is
empty !
With MenuSheet
MenuLevel = .Cells(Row, 1)
Caption = .Cells(Row, 2)
PositionOrMacro = .Cells(Row, 3)
Divider = .Cells(Row, 4)
FaceId = .Cells(Row, 5)
NextLevel = .Cells(Row + 1, 1)
End With

Select Case MenuLevel
Case 1 ' A Menu - Add the top-level menu to the Worksheet
CommandBar
Set MenuObject = Application.CommandBars(1). _
Controls.Add(Type:=msoControlPopup, _
Befo=PositionOrMacro, _
Temporary:=True)
MenuObject.Caption = Caption

Case 2 ' A Menu Item.
If NextLevel = 3 Then
Set MenuItem =
MenuObject.Controls.Add(Type:=msoControlPopup)
Else
Set MenuItem =
MenuObject.Controls.Add(Type:=msoControlButton)
MenuItem.OnAction = PositionOrMacro
'#######################
End If

and I suspect we need simplify to qualify the references to
PositionOrMacro in the line:-

MenuItem.OnAction = PositionOrMacro

with the word ActiveWorkbook, but the syntax has defeated us.

John - if you are there, can you help us, failing which any lesser
beings ?

Your help will be very greatly appreciated.

Charles
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Syntax problem in defining OnAction macro definition held in Add-in!

I am not sure wherein your code you get the error, but keep in mind
that an add in is never the ActiveWorkbook, if you need a reference to
it, you should use Thisworkbook (where the code that is running
resides)

Rgsd
Mika

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Syntax problem in defining OnAction macro definition held in Add-in!

Charles,

To see the format you need, add a button from the forms toolbar to a
spreadsheet. The choices of macros to assign that come up will be in the
format you want. I suspect that you are missing two single-quotes and a "!"
and that your new line will be:

"'" & ActiveWorkbook.Name & "'!" & PositionOrMacro

What I do is just put the full qualified name in the menusheet, e.g.,:

'MyBook.xls'!MyMacro


hth,

Doug Glancy

"Charles Jordan" wrote in message
om...
Hi. I am using a modified version of John Walkenbach's outstanding
MenuMaker.xls to create a table driven Command bar structure.

(1) However the lookup table instead of being in the ActiveworkBook,
is in an add-in, in a worksheet, "Menusheet" in C1menus.xla, and the
cells in column 3 of this sheet each hold the names of the OnAction
macros.

(2) These macros however, which the menu items call, continue to be in
the ActiveworkBook, but when the menu item is invoked we get an error
message "The macro C1menus.xla!FixAll" cannot be found".

John Walkenbach's MenuMaker.xls code, slightly modified, in the add-in
is as follows:

Dim PositionOrMacro

Set MenuSheet = ThisWorkbook.Sheets("Menusheet") 'Location for menu
data
' Make sure the menus aren't duplicated
Call DeleteMenu
' Initialize the row counter
Row = 4
' Add the menus, menu items and submenu items using data stored on
MenuSheet

Do Until IsEmpty(MenuSheet.Cells(Row, 1)) 'stop when column 1 is
empty !
With MenuSheet
MenuLevel = .Cells(Row, 1)
Caption = .Cells(Row, 2)
PositionOrMacro = .Cells(Row, 3)
Divider = .Cells(Row, 4)
FaceId = .Cells(Row, 5)
NextLevel = .Cells(Row + 1, 1)
End With

Select Case MenuLevel
Case 1 ' A Menu - Add the top-level menu to the Worksheet
CommandBar
Set MenuObject = Application.CommandBars(1). _
Controls.Add(Type:=msoControlPopup, _
Befo=PositionOrMacro, _
Temporary:=True)
MenuObject.Caption = Caption

Case 2 ' A Menu Item.
If NextLevel = 3 Then
Set MenuItem =
MenuObject.Controls.Add(Type:=msoControlPopup)
Else
Set MenuItem =
MenuObject.Controls.Add(Type:=msoControlButton)
MenuItem.OnAction = PositionOrMacro
'#######################
End If

and I suspect we need simplify to qualify the references to
PositionOrMacro in the line:-

MenuItem.OnAction = PositionOrMacro

with the word ActiveWorkbook, but the syntax has defeated us.

John - if you are there, can you help us, failing which any lesser
beings ?

Your help will be very greatly appreciated.

Charles



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Syntax problem in defining OnAction macro definition held in Add-in!

"Doug Glancy" wrote in message ...
Charles,

To see the format you need, add a button from the forms toolbar to a
spreadsheet. The choices of macros to assign that come up will be in the
format you want. I suspect that you are missing two single-quotes and a "!"
and that your new line will be:

"'" & ActiveWorkbook.Name & "'!" & PositionOrMacro

What I do is just put the full qualified name in the menusheet, e.g.,:

'MyBook.xls'!MyMacro


hth,

Doug Glancy


Thanks a million Doug - just a little syntax problem..Charles

"Charles Jordan" wrote in message
om...
Hi. I am using a modified version of John Walkenbach's outstanding
MenuMaker.xls to create a table driven Command bar structure.

(1) However the lookup table instead of being in the ActiveworkBook,
is in an add-in, in a worksheet, "Menusheet" in C1menus.xla, and the
cells in column 3 of this sheet each hold the names of the OnAction
macros.

(2) These macros however, which the menu items call, continue to be in
the ActiveworkBook, but when the menu item is invoked we get an error
message "The macro C1menus.xla!FixAll" cannot be found".

John Walkenbach's MenuMaker.xls code, slightly modified, in the add-in
is as follows:

Dim PositionOrMacro

Set MenuSheet = ThisWorkbook.Sheets("Menusheet") 'Location for menu
data
' Make sure the menus aren't duplicated
Call DeleteMenu
' Initialize the row counter
Row = 4
' Add the menus, menu items and submenu items using data stored on
MenuSheet

Do Until IsEmpty(MenuSheet.Cells(Row, 1)) 'stop when column 1 is
empty !
With MenuSheet
MenuLevel = .Cells(Row, 1)
Caption = .Cells(Row, 2)
PositionOrMacro = .Cells(Row, 3)
Divider = .Cells(Row, 4)
FaceId = .Cells(Row, 5)
NextLevel = .Cells(Row + 1, 1)
End With

Select Case MenuLevel
Case 1 ' A Menu - Add the top-level menu to the Worksheet
CommandBar
Set MenuObject = Application.CommandBars(1). _
Controls.Add(Type:=msoControlPopup, _
Befo=PositionOrMacro, _
Temporary:=True)
MenuObject.Caption = Caption

Case 2 ' A Menu Item.
If NextLevel = 3 Then
Set MenuItem =
MenuObject.Controls.Add(Type:=msoControlPopup)
Else
Set MenuItem =
MenuObject.Controls.Add(Type:=msoControlButton)
MenuItem.OnAction = PositionOrMacro
'#######################
End If

and I suspect we need simplify to qualify the references to
PositionOrMacro in the line:-

MenuItem.OnAction = PositionOrMacro

with the word ActiveWorkbook, but the syntax has defeated us.

John - if you are there, can you help us, failing which any lesser
beings ?

Your help will be very greatly appreciated.

Charles

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Syntax problem in defining OnAction macro definition held in Add-in!

"Doug Glancy" wrote in message ...
Charles,

To see the format you need, add a button from the forms toolbar to a
spreadsheet. The choices of macros to assign that come up will be in the
format you want. I suspect that you are missing two single-quotes and a "!"
and that your new line will be:

"'" & ActiveWorkbook.Name & "'!" & PositionOrMacro

What I do is just put the full qualified name in the menusheet, e.g.,:

'MyBook.xls'!MyMacro


hth,

Doug Glancy


Thanks a million Doug - just a little syntax problem..Charles

"Charles Jordan" wrote in message
om...
Hi. I am using a modified version of John Walkenbach's outstanding
MenuMaker.xls to create a table driven Command bar structure.

(1) However the lookup table instead of being in the ActiveworkBook,
is in an add-in, in a worksheet, "Menusheet" in C1menus.xla, and the
cells in column 3 of this sheet each hold the names of the OnAction
macros.

(2) These macros however, which the menu items call, continue to be in
the ActiveworkBook, but when the menu item is invoked we get an error
message "The macro C1menus.xla!FixAll" cannot be found".

John Walkenbach's MenuMaker.xls code, slightly modified, in the add-in
is as follows:

Dim PositionOrMacro

Set MenuSheet = ThisWorkbook.Sheets("Menusheet") 'Location for menu
data
' Make sure the menus aren't duplicated
Call DeleteMenu
' Initialize the row counter
Row = 4
' Add the menus, menu items and submenu items using data stored on
MenuSheet

Do Until IsEmpty(MenuSheet.Cells(Row, 1)) 'stop when column 1 is
empty !
With MenuSheet
MenuLevel = .Cells(Row, 1)
Caption = .Cells(Row, 2)
PositionOrMacro = .Cells(Row, 3)
Divider = .Cells(Row, 4)
FaceId = .Cells(Row, 5)
NextLevel = .Cells(Row + 1, 1)
End With

Select Case MenuLevel
Case 1 ' A Menu - Add the top-level menu to the Worksheet
CommandBar
Set MenuObject = Application.CommandBars(1). _
Controls.Add(Type:=msoControlPopup, _
Befo=PositionOrMacro, _
Temporary:=True)
MenuObject.Caption = Caption

Case 2 ' A Menu Item.
If NextLevel = 3 Then
Set MenuItem =
MenuObject.Controls.Add(Type:=msoControlPopup)
Else
Set MenuItem =
MenuObject.Controls.Add(Type:=msoControlButton)
MenuItem.OnAction = PositionOrMacro
'#######################
End If

and I suspect we need simplify to qualify the references to
PositionOrMacro in the line:-

MenuItem.OnAction = PositionOrMacro

with the word ActiveWorkbook, but the syntax has defeated us.

John - if you are there, can you help us, failing which any lesser
beings ?

Your help will be very greatly appreciated.

Charles

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
Copy And Paste Macro Syntax Problem Minitman Excel Worksheet Functions 2 March 27th 08 01:59 AM
Solver Problem Definition testspecmed Excel Worksheet Functions 0 October 5th 06 07:06 PM
Timing problem with OnAction! Fred Russell Charts and Charting in Excel 3 October 18th 05 06:11 PM
Problem with Button OnAction property... fausto Excel Programming 2 February 26th 05 07:50 AM
Range definition problem Peter Chatterton[_2_] Excel Programming 6 November 18th 04 08:05 PM


All times are GMT +1. The time now is 07:04 AM.

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"