LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Strong-arm tactic for enabling Macro

Hi,

I came across a post in the group where one could hide sheets if macros
arent enabled and unhide them only if they are enabled, so that user is
forced to enable them.

I have a spreadsheet where Im getting data filed from different people. It
has 3 worksheets out of which worksheet "Raw Data" is for entering data,
"Instructions" is basically a guideline/help file sort of thing containing
text on how the data in Raw data worksheet is to be entered. Im using lots
of macros in Raw Data worksheet to check for internal data inconsistencies
so that in case of problems the person entering data could correct it rather
than me sending back and asking for corrected version.

The third worksheet "Warning" is basically tells the user to enable macros.

I wrote the following code and inserted it in workbook module.

Option Explicit
Private Sub Workbook_Open()

Sheets("Instructions").Visible = True
Sheets("Raw Data").Visible = True
Sheets("Warning").Visible = xlVeryHidden
ActiveWorkbook.Save

End Sub

Private Sub Workbook_beforeclose(Cancel As Boolean)
If ActiveWorkbook.Saved = True Then

Sheets("Warning").Visible = True
Sheets("Instructions").Visible = xlVeryHidden
Sheets("Raw Data").Visible = xlVeryHidden
ActiveWorkbook.Save
Cancel = False

Else

MsgBox "Please save the workbook before exiting"
Cancel = True

End If

End Sub

Please note it seems to work as I wanted but I wanted to know is whether am
missing something in the above code (I mean logic wise).

Also is there a more efficient way of writing (or getting the macro
executed) in the above macro.


Regards,
Hari
India


 
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
is microsoft strong cryptographic provider encryption good enough kutchbhi Excel Discussion (Misc queries) 0 January 10th 10 08:17 AM
How to delete a row if strong NOT found.... JayKay100 Excel Discussion (Misc queries) 9 November 23rd 08 06:20 AM
Enabling Macro with the worksheet file NSNR Excel Discussion (Misc queries) 2 October 26th 07 12:16 PM
re-enabling macro under menu item jerry h Excel Programming 1 April 18th 04 12:14 AM
XLA and strong typing [email protected] Excel Programming 0 October 30th 03 07:53 PM


All times are GMT +1. The time now is 05:26 PM.

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"