Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Locking a sheet & Menu Items

Hi ~

Does anyone know how to lock an excel sheet using VBA? I have an excel
sheet that is set perfectly according to my coordinates. It loops
through various sections of the sheets, giving it the impression that
you're scrolling through pages (much like web pages). But if I resize
the sheet in anyway, the display gets messed up and not pretty.

2ndly, I want to create my own menu in Excel. Right now, I've created
a sheet of all the captions and actions that the menu items will do.
I'm running into a problem when it comes to submenu items. For
example, my menu items are menu1, menu2, menu3, menu4; my submenu items
are submenu1, submenu2. Menu2 and Menu4 have these submenus and the
other 2 doesn't. I've created a "for" loop to go through each of those
cells, but when it comes to the submenu items, an error gets displayed.

Can anyone help me out with this? Thanks in advance.

Denny.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Add: Locking a sheet & Menu Items

Ok, here's a bit more info. I'm creating a custom menu and this is a
brief version of my code. I know that Case 2 - 5 is very redundant
code, but I'm not sure how to condense it more.

Also, I'm not sure if this is even possible, but I'm trying to create a
conditional column in my spreadsheet. This column would show me a list
of parameters for a function to check against. For example,
conditional column says (a,b). Since there is 2 parameters, the
program would get the delimiter count and go to the appropriate
function based on the number of parameters, because the parameters
could increase or decrease based on a particular function. Therefore,
"a" and "b" would be passed to the function that accepts the 2
parameters and validates them and returns true or false. I could then
proceed to the next row and condition. Thanks for your input.


Here's my code:
Do Until IsEmpty(MenuSheet.Cells(Row, 1))
With MenuSheet
MenuLevel = .Cells(Row, 1)
Caption = .Cells(Row, 2)
PositionOrAction = .Cells(Row, 3)
Divider = .Cells(Row, 4)
FaceId = .Cells(Row, 5)
NextLevel = .Cells(Row + 1, 1)
Conditional = .Cells(Row, 6)
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=PositionOrAction, _
Temporary:=True)
MenuObject.Caption = Caption

Case 2 ' A Menu Item
If Conditional < "" Then
If Not (WizardCondition) Then
Set MenuItem = _

MenuObject.Controls.Add(Type:=msoControlButton)
MenuItem.OnAction = PositionOrAction
MenuItem.Caption = Caption
If FaceId < "" Then MenuItem.FaceId = FaceId
End If
Else
If NextLevel = 3 Then
Set MenuItem = _

MenuObject.Controls.Add(Type:=msoControlPopup)
Else
Set MenuItem = _

MenuObject.Controls.Add(Type:=msoControlButton)
MenuItem.OnAction = PositionOrAction
End If
MenuItem.Caption = Caption
If FaceId < "" Then MenuItem.FaceId = FaceId
If Divider Then MenuItem.BeginGroup = True
End If

Case 3 ' A SubMenuLevel1 Item
If NextLevel = 4 Then
Set SubMenuLev1Item = _
MenuItem.Controls.Add(Type:=msoControlPopup)
Else
Set SubMenuLev1Item = _
MenuItem.Controls.Add(Type:=msoControlButton)
'SubMenuLev1Item.OnAction = PositionOrAction
End If
SubMenuLev1Item.Caption = Caption
If FaceId < "" Then SubMenuLev1Item.FaceId = FaceId
If Divider Then SubMenuLev1Item.BeginGroup = True

Case 4 ' A SubMenuLevel2 Item
If NextLevel = 5 Then
Set SubMenuLev2Item = _

SubMenuLev1Item.Controls.Add(Type:=msoControlPopup )
Else
Set SubMenuLev2Item = _

SubMenuLev1Item.Controls.Add(Type:=msoControlButto n)
'SubMenuLev2Item.OnAction = PositionOrAction
End If
SubMenuLev2Item.Caption = Caption
If FaceId < "" Then SubMenuLev2Item.FaceId = FaceId
If Divider Then SubMenuLev2Item.BeginGroup = True

Case 5 ' A SubMenuLevel3 Item
Set SubMenuLev3Item = _

SubMenuLev2Item.Controls.Add(Type:=msoControlButto n)
SubMenuLev3Item.Caption = Caption
'SubMenuLev3Item.OnAction = PositionOrAction
If FaceId < "" Then SubMenuLev3Item.FaceId = FaceId
If Divider Then SubMenuLev3Item.BeginGroup = True
End Select
Row = Row + 1
Loop


wrote:
Hi ~

Does anyone know how to lock an excel sheet using VBA? I have an excel
sheet that is set perfectly according to my coordinates. It loops
through various sections of the sheets, giving it the impression that
you're scrolling through pages (much like web pages). But if I resize
the sheet in anyway, the display gets messed up and not pretty.

2ndly, I want to create my own menu in Excel. Right now, I've created
a sheet of all the captions and actions that the menu items will do.
I'm running into a problem when it comes to submenu items. For
example, my menu items are menu1, menu2, menu3, menu4; my submenu items
are submenu1, submenu2. Menu2 and Menu4 have these submenus and the
other 2 doesn't. I've created a "for" loop to go through each of those
cells, but when it comes to the submenu items, an error gets displayed.

Can anyone help me out with this? Thanks in advance.

Denny.


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
Menu items Pietro Excel Discussion (Misc queries) 2 March 1st 07 10:41 AM
locking formula in cells in without locking whole sheet SuziQ Excel Discussion (Misc queries) 1 July 21st 06 03:58 PM
New menu items Daniel Bonallack Excel Programming 2 November 2nd 05 07:59 PM
Menu items added with menu item editor in older versions Michael Hoffmann Excel Discussion (Misc queries) 2 January 7th 05 01:40 PM
Sub Menu Items pauluk[_72_] Excel Programming 1 July 27th 04 12:23 PM


All times are GMT +1. The time now is 11:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"