Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This assumes you have a workbook with say 5 sheets (Doesn't matter how many or
what they are called - Other than the Warning sheet which must be called warning in this case - or simply change the macro to reflect the name you give it):- 1 - 'Warning' 2 - 'Sht 1' 3 - 'Sht 2' 4 - 'Sht 3' 5 - 'Sht 4' Whilst in the VBE (ALT+F11), put the following code into the 'ThisWorkbook' module:- Private Sub Workbook_Open() Application.ScreenUpdating = False For i = 1 To Worksheets.Count Sheets(i).Visible = True Next i Sheets("Warning").Visible = xlVeryHidden Application.ScreenUpdating = True End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.ScreenUpdating = False For i = 1 To Worksheets.Count Sheets("Warning").Visible = True If Sheets(i).Visible = True And Sheets(i).Name < "Warning" Then Sheets(i).Visible = xlVeryHidden End If Next i Application.DisplayAlerts = False ActiveWorkbook.Save End Sub As long as macros were enabled, then this will hide the warning sheet and display all the other sheets Finally you need to protect the VBA code so no-one can see it and work out what's going on, so Hit ALT+F11 - take a look at the top left of your screen, and hopefully you will see a window entitled VBA Project Explorer. In this window there will be a list of filenames, just like the folder names in an Explorer window. Find the name of your file in that window and right click on your workbook name and then from the menu that pops up, select VBAProject properties. This will then give you a grey dialog box with two tabs. Click on the Protection Tab, put a tick in the 'Lock Project for viewing' option, put in a password and confirm it below, then hit OK. Do File / Save Workbookname, File Close and return to Excel, then close file and reopen. You should now not be able to get to the VBAProject Code if you go into the VBE. NOTE:- This use the Before_close event to hide the sheets, so that it is ready to start afresh next time, BUT, if they are closing because they just don't want to save the changes they made, then the code is going to save anyway to ensure the sheets are hidden by default on opening. -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 00/02/03 ---------------------------------------------------------------------------- It's easier to beg forgiveness than ask permission :-) ---------------------------------------------------------------------------- "Martyn" wrote in message ... Ken, considering there are lots of macro programming beginners in this NG could you please set a clear example how we can do that? TIA --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.613 / Virus Database: 392 - Release Date: 04/03/2004 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Force users to enable macros when open a workbook | New Users to Excel | |||
How can force enable macros to be able to open my workbook? | Excel Discussion (Misc queries) | |||
Force Enable Macros | Excel Programming | |||
Force Enable Macros | Excel Programming | |||
Force Enable Macros | Excel Programming |