LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Force Enable Macros

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
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
Force users to enable macros when open a workbook Tan New Users to Excel 2 April 15th 07 05:09 PM
How can force enable macros to be able to open my workbook? kcdonaldson Excel Discussion (Misc queries) 3 December 5th 05 06:16 PM
Force Enable Macros Jake Marx[_2_] Excel Programming 1 October 24th 03 01:24 AM
Force Enable Macros Alan Excel Programming 0 September 24th 03 08:17 PM
Force Enable Macros Ed[_9_] Excel Programming 0 September 24th 03 07:59 PM


All times are GMT +1. The time now is 02:43 AM.

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"