#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macros

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Macros

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Macros

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
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
choose default macros Not Enabled / Macros Enable Setting BEEJAY Excel Programming 2 June 30th 06 01:07 PM
weird saving of a document with macros resulting with macros being transfered to the copy alfonso gonzales Excel Programming 0 December 12th 04 09:19 PM
Macros inside macros, and pasting into macro code. pagelocator[_2_] Excel Programming 1 November 24th 04 09:11 AM
convert lotus 123w macros to excel macros rpiescik Excel Programming 1 September 18th 04 01:35 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM


All times are GMT +1. The time now is 06:46 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"