Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Forgive me if my questions is too basic but I am not a developer. I
would like to know if there is nayway that I can have an excel sheet close out if macros are not enabled? If not, is there a way to make sheets not visible if Macros are not enabled? Thanks for any help |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you are refering to the enable or disable macros message box when a
workbook opens than no, as far as my knowledge of vba goes. When you open a workbook and the user disables macros then any macros in that workbook will not execute, so any code to hide a sheet or close a workbook will not run. Sandy wrote: Forgive me if my questions is too basic but I am not a developer. I would like to know if there is nayway that I can have an excel sheet close out if macros are not enabled? If not, is there a way to make sheets not visible if Macros are not enabled? Thanks for any help |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you are refering to the enable or disable macros message box when a
workbook opens than no, as far as my knowledge of vba goes. When you open a workbook and the user disables macros then any macros in that workbook will not execute, so any code to hide a sheet or close a workbook will not run. In order to work around this will take some coding in a specific area. You'll need to hide all your sheets that you don't want visible if the user doesn't enable macros in the Workbook_BeforeClose event, and you'll need to write the Workbook_Open event that will make the previous sheets visible. Now this alone will work, but if any intermediate excel user knows there way around excel they could just manually unhide the sheets after denying the macros from running, so you'll have to disable the sheets menu on the format dropdown and add it to the Workbook_BeforeClose event. Below is the different bits of code to get this to work. Open VBE (Alt + F11) Open Project explorer (Ctrl + r) Double click on ThisWorkbook under your workbook and paste the code below 'Hides Sheet1 and Sheeet2 and disables the format-sheet menu Private Sub Workbook_BeforeClose(Cancel As Boolean) Worksheets("Sheet1").Visible = False Worksheets("Sheet2").Visible = False Application.CommandBars("Worksheet Menu Bar") _ ..Controls("Format").Controls("Sheet").Enabled = False ActiveWorkbook.Save End Sub 'Un-hides the sheets and enables the format-sheet menu Private Sub Workbook_Open() Worksheets("Sheet1").Visible = True Worksheets("Sheet2").Visible = True Application.CommandBars("Worksheet Menu Bar") _ ..Controls("Format").Controls("Sheet").Enabled = True End Sub HTH & let me know how it worked out... Sandy wrote: Forgive me if my questions is too basic but I am not a developer. I would like to know if there is nayway that I can have an excel sheet close out if macros are not enabled? If not, is there a way to make sheets not visible if Macros are not enabled? Thanks for any help |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
choose default macros Not Enabled / Macros Enable Setting | Excel Programming | |||
weird saving of a document with macros resulting with macros being transfered to the copy | Excel Programming | |||
Macros inside macros, and pasting into macro code. | Excel Programming | |||
convert lotus 123w macros to excel macros | Excel Programming | |||
Macros not appearing in the Tools Macro Macros list | Excel Programming |