Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
With the code you provided
it takes away the command bars but didn't restore them. Standard & Formatting didn't return. I just tried the code again and it seems to work fine for me, ie disables the named toolbars and re-enables according to saved settings. Put the cursor in the Workbook_Activate event, press F5 to run myToolbars False. The original Not-Enabled settings for the toolbars should be saved on Sheet1. The reason for saving the Not-enabled settings is if for any reason the values are removed, cells will be read as Not False, ie True. With the toolbars disabled put the cursor in the Workbook_Deactivate and run ' myToolbars True'. This should pick up the saved Not-Enabled values and apply to the original toolbars enabled properties. If this is all working try and verify in particular if the Workbook_Deactivate is working as anticipated, both when another workbook is activated and when the file is closed. Regards, Peter T "mikeolson" wrote in message ... Peter, I am so close to getting it to do what I want. With the code you provided it takes away the command bars but didn't restore them. Standard & Formatting didn't return. The old code I used removed all the toolbars when I opened my Spreadsheet, the problem came in when I need the toolbars for another open workbook, hence my original question and your response. The reason I need the toolbars disabled in the one workbook is there are several password protected components that I need safeguarded and additionally to protect formulas I disabled right-click menus, Ctl+C, Ctrl+X, and so on so that one cell isn't moved to another throwing off a formula calculation, anyway to my point. I currently have a password protected access that when entered correctly, unlocked the workbook, restored the toolbars so that I could enter Visual Basic and make modifications as need or other tweeks, so I need it protected so the end user can only utilize what I want them to but with my password enable everything so I can make changes. Thank you again for all your help on this. If would need some of my old code posted so you can see what I had, please let me know. Mike "Peter T" wrote: The ActiveWindow settings are mixture of worksheet and worrkbook specific settings which you can save with your workbook. I don't like code that messes with my toolbars as typically something goes wrong and they don't get reset. Hopefully this is relatively safe but not completely, original settings are stored on Sheet1 in your wb which you can rename & hide: ' Thisworkbook module Private Sub Workbook_Activate() myToolbars False End Sub Private Sub Workbook_Deactivate() myToolbars True End Sub ' Normal Module Sub myToolbars(bReset As Boolean) Dim n As Long, ub As Long Dim vBars, vBarsOrig Dim cBar As CommandBar, cbCtr As CommandBarControl Dim rng As Range vBars = Array("dummy", "Formatting", "Standard", "Drawing") ' others ? ub = UBound(vBars) ReDim vBarsOrig(1 To ub, 1 To 2) Set rng = ThisWorkbook.Worksheets("Sheet1").Range("B1:C" & ub) If bReset Then vBarsOrig = rng.Value Else ReDim vBarsOrig(1 To ub, 1 To 1) End If Set cBar = Application.CommandBars("Worksheet Menu Bar") For Each cbCtr In cBar.Controls If cbCtr.ID < 30002 Then ' File menu cbCtr.Visible = bReset End If Application.DisplayFormulaBar = bReset Next For n = 1 To UBound(vBars) Set cBar = Application.CommandBars(vBars(n)) With cBar If bReset Then .Enabled = Not vBarsOrig(n, 1) Else vBarsOrig(n, 1) = Not .Enabled .Enabled = False End If End With Next If Not bReset Then rng.Value = vBarsOrig End If End Sub Sub ResetToolbars() myToolbars True End Sub Would need to Ctrl-tab to other workbooks. Regards, Peter T "mikeolson" wrote in message ... Here's the code I currently have in the workbook, and again my goal is to have these toolbar settings effect this workbook only so that when I open another workbook blank or otherwise it has the default toolbars in place: Private Sub Workbook_BeforeClose Application.DisplayFormulaBar = True Application.CommandBars("Standard").Visible = True Application.CommandBars("Formatting").Visible = True Application.CommandBars("Edit").Enabled = True Application.CommandBars("Tools").Enabled = True Application.CommandBars("Format").Enabled = True Application.CommandBars("Data").Enabled = True Application.CommandBars("Insert").Enabled = True Application.CommandBars("View").Enabled = True Application.CommandBars("Worksheet Menu Bar").Enabled = True Application.DisplayFullScreen = False Application.DisplayFormulaBar = True Application.CommandBars("Standard").Visible = True Application.CommandBars("Formatting").Visible = True Application.CommandBars("Edit").Enabled = True Application.CommandBars("Tools").Enabled = True Application.CommandBars("Format").Enabled = True Application.CommandBars("Data").Enabled = True Application.CommandBars("Insert").Enabled = True Application.CommandBars("View").Enabled = True Application.CommandBars("Worksheet Menu Bar").Enabled = True 'Restore heading and tabs and gridlines With ActiveWindow .DisplayWorkbookTabs = True .DisplayHeadings = True .DisplayGridlines = False .DisplayHorizontalScrollBar = True .DisplayVerticalScrollBar = True Private Sub Workbook_Open() 'Disable macro menu Application.CommandBars("Worksheet Menu Bar").Visible = True Application.CommandBars("Worksheet Menu Bar").Enabled = False Application.CommandBars("Tools").Enabled = False Application.CommandBars("Edit").Enabled = False Application.CommandBars("Format").Enabled = False Application.CommandBars("Data").Enabled = False Application.CommandBars("Insert").Enabled = False Application.CommandBars("View").Enabled = False 'Remove heading and tabs and gridlines Application.DisplayFormulaBar = False With ActiveWindow .DisplayWorkbookTabs = False .DisplayHeadings = False .DisplayGridlines = False .DisplayZeros = True .DisplayHorizontalScrollBar = False .DisplayVerticalScrollBar = False Is it the application.commandbars that should read something other than application, or do I still need to move this code someplace else? Thanks for your help on this. Mike |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Open a separate Excel Program in a new window | Excel Discussion (Misc queries) | |||
How can I open from Web Excel Files in a separate Window? | Excel Discussion (Misc queries) | |||
can't open new worksheets in a separate window | Excel Discussion (Misc queries) | |||
Open separate window | Excel Worksheet Functions | |||
Open Workbook in separate window | Excel Programming |