Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default menu bar keyboard shortcuts intermittent.

I create a custom menu using the routine shown at the bottom of this
message which was generously created by individual unknown to whom I am
indebted to making my life easier.

When the macro is run, the menu bar shows across the top of the sheet:

File with an underline under the F
Edit with an underline under the E
.....
....
....
Actions List with an underline under the L

Prior to my machine crashing and reloading of the operating system,
depressing Alt-L opened the "Actions List" pull down menu. Now I usually
have to press Alt-L followed by "Enter" to get the same operation. The
standard menu items, File, Edit, View, Insert ... continue to open
merely by the appropriate Alt-letter combination.

Earlier today, for an unknown reason, Alt-L was opening the Action-List
pull down menu. This evening it again doesn't work.

WHAT MIGHT BE CHANGING?

Thanks ... WindsurferLA

- - - - - - - -

Sub CreateMenu()
' This sub should be executed when the workbook is opened.
' NOTE: There is no error handling in this subroutine

Dim MenuSheet As Worksheet
Dim MenuObject As CommandBarPopup

Dim MenuItem As Object
Dim SubMenuItem As CommandBarButton
Dim Row As Integer
Dim MenuLevel, nextlevel, PositionOrMacro, Caption, Divider, FaceId

'''''''''''''''''''''''''''''''''''''''''''''''''' ''
' Location for menu data
Set MenuSheet = ThisWorkbook.Sheets("MenuSheet")
'''''''''''''''''''''''''''''''''''''''''''''''''' ''

' Make sure the menus aren't duplicated
Call DeleteMenu

' Initialize the row counter
Row = 2

' Add the menus, menu items and submenu items using
' data stored on MenuSheet

Do Until IsEmpty(MenuSheet.Cells(Row, 1))
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
MenuItem.Caption = Caption
If FaceId < "" Then MenuItem.FaceId = FaceId
If Divider Then MenuItem.BeginGroup = True

Case 3 ' A SubMenu Item
Set SubMenuItem =
MenuItem.Controls.Add(Type:=msoControlButton)
SubMenuItem.Caption = Caption
SubMenuItem.OnAction = PositionOrMacro
If FaceId < "" Then SubMenuItem.FaceId = FaceId
If Divider Then SubMenuItem.BeginGroup = True
End Select
Row = Row + 1
Loop
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default menu bar keyboard shortcuts intermittent.

Hello
I haven't been through all of your code, so this is just a suggestion:
You are using "reserved" names as variables in your code ie:
Caption and FaceId (both existing properties in VBA)
I would recommend you amend these variables names with for example
"ItCaption" and "ItFaceId"

HTH
Cordially
Pascal

"windsurferLA" a écrit dans le message de news:
...
I create a custom menu using the routine shown at the bottom of this
message which was generously created by individual unknown to whom I am
indebted to making my life easier.

When the macro is run, the menu bar shows across the top of the sheet:

File with an underline under the F
Edit with an underline under the E
....
...
...
Actions List with an underline under the L

Prior to my machine crashing and reloading of the operating system,
depressing Alt-L opened the "Actions List" pull down menu. Now I usually
have to press Alt-L followed by "Enter" to get the same operation. The
standard menu items, File, Edit, View, Insert ... continue to open merely
by the appropriate Alt-letter combination.

Earlier today, for an unknown reason, Alt-L was opening the Action-List
pull down menu. This evening it again doesn't work.

WHAT MIGHT BE CHANGING?

Thanks ... WindsurferLA

- - - - - - - -

Sub CreateMenu()
' This sub should be executed when the workbook is opened.
' NOTE: There is no error handling in this subroutine

Dim MenuSheet As Worksheet
Dim MenuObject As CommandBarPopup

Dim MenuItem As Object
Dim SubMenuItem As CommandBarButton
Dim Row As Integer
Dim MenuLevel, nextlevel, PositionOrMacro, Caption, Divider, FaceId

'''''''''''''''''''''''''''''''''''''''''''''''''' ''
' Location for menu data
Set MenuSheet = ThisWorkbook.Sheets("MenuSheet")
'''''''''''''''''''''''''''''''''''''''''''''''''' ''

' Make sure the menus aren't duplicated
Call DeleteMenu

' Initialize the row counter
Row = 2

' Add the menus, menu items and submenu items using
' data stored on MenuSheet

Do Until IsEmpty(MenuSheet.Cells(Row, 1))
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
MenuItem.Caption = Caption
If FaceId < "" Then MenuItem.FaceId = FaceId
If Divider Then MenuItem.BeginGroup = True

Case 3 ' A SubMenu Item
Set SubMenuItem =
MenuItem.Controls.Add(Type:=msoControlButton)
SubMenuItem.Caption = Caption
SubMenuItem.OnAction = PositionOrMacro
If FaceId < "" Then SubMenuItem.FaceId = FaceId
If Divider Then SubMenuItem.BeginGroup = True
End Select
Row = Row + 1
Loop
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default menu bar keyboard shortcuts intermittent.

Hi
you would have to use the "reserved" names.

No, you should *always* avoid using reserved names in variables.
Caption and FaceID are not just any variables, they are the representations
that go in the menu bar.

I understand your confusion, but still they ARE variables.
These names (Caption and FaceId) are properties available via VBA.
When they are both used as properties and variables (see your code snippet
below) your code may not work properly.

MenuItem.Caption = Caption
If FaceId < "" Then MenuItem.FaceId = FaceId



HTH
Cordially
Pascal


"windsurferLA" a écrit dans le message de news:
...
I'm not an expert on Menu generating programs, but I would think that you
would have to use the "reserved" names. Caption and FaceID are not just
any variables, they are the representations that go in the menu bar. Am I
wrong?

WindsurferLA



papou wrote:
Hello
I haven't been through all of your code, so this is just a suggestion:
You are using "reserved" names as variables in your code ie:
Caption and FaceId (both existing properties in VBA)
I would recommend you amend these variables names with for example
"ItCaption" and "ItFaceId"

HTH
Cordially
Pascal

"windsurferLA" a écrit dans le message de news:
...

I create a custom menu using the routine shown at the bottom of this
message which was generously created by individual unknown to whom I am
indebted to making my life easier.

When the macro is run, the menu bar shows across the top of the sheet:

File with an underline under the F
Edit with an underline under the E
....
...
...
Actions List with an underline under the L

Prior to my machine crashing and reloading of the operating system,
depressing Alt-L opened the "Actions List" pull down menu. Now I usually
have to press Alt-L followed by "Enter" to get the same operation. The
standard menu items, File, Edit, View, Insert ... continue to open merely
by the appropriate Alt-letter combination.

Earlier today, for an unknown reason, Alt-L was opening the Action-List
pull down menu. This evening it again doesn't work.

WHAT MIGHT BE CHANGING?

Thanks ... WindsurferLA

- - - - - - - -

Sub CreateMenu()
' This sub should be executed when the workbook is opened.
' NOTE: There is no error handling in this subroutine

Dim MenuSheet As Worksheet
Dim MenuObject As CommandBarPopup

Dim MenuItem As Object
Dim SubMenuItem As CommandBarButton
Dim Row As Integer
Dim MenuLevel, nextlevel, PositionOrMacro, Caption, Divider, FaceId

''''''''''''''''''''''''''''''''''''''''''''''' '''''
' Location for menu data
Set MenuSheet = ThisWorkbook.Sheets("MenuSheet")
''''''''''''''''''''''''''''''''''''''''''''''' '''''

' Make sure the menus aren't duplicated
Call DeleteMenu

' Initialize the row counter
Row = 2

' Add the menus, menu items and submenu items using
' data stored on MenuSheet

Do Until IsEmpty(MenuSheet.Cells(Row, 1))
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
MenuItem.Caption = Caption
If FaceId < "" Then MenuItem.FaceId = FaceId
If Divider Then MenuItem.BeginGroup = True

Case 3 ' A SubMenu Item
Set SubMenuItem =
MenuItem.Controls.Add(Type:=msoControlButton)
SubMenuItem.Caption = Caption
SubMenuItem.OnAction = PositionOrMacro
If FaceId < "" Then SubMenuItem.FaceId = FaceId
If Divider Then SubMenuItem.BeginGroup = True
End Select
Row = Row + 1
Loop
End Sub




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
Keyboard Shortcuts jovch Excel Discussion (Misc queries) 1 August 25th 08 07:57 PM
Keyboard Shortcuts wnfisba Excel Discussion (Misc queries) 3 December 8th 06 07:11 PM
Keyboard shortcuts Greka Excel Discussion (Misc queries) 5 July 18th 06 04:38 PM
Keyboard shortcuts Scott Excel Discussion (Misc queries) 2 January 25th 06 04:51 AM
KEYBOARD SHORTCUTS rm Excel Discussion (Misc queries) 8 May 18th 05 08:48 AM


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