Solved

Excel 2007 VBA prevent workbook use with macros disabled

Posted on 2012-03-23
6
322 Views
Last Modified: 2012-06-18
Does anyone have any good ideas to stop use of a workbook when macros are disabled? I have some code in the Worksheet_Change and WorkSheet_SelectionChange that stops users inadvertently changing certain things.  I can't use protection for this some data is in a table and if the cells are protected the users can't sort and filter.

If they disable macros when the worbook opens they'll be able to change everything.  I thought of something like making the key sheets hidden and only unhiding them in Workbook_Open code, then hiding again when they close.  But if they start up, do some work, save, do some more work then close without saving changes, the sheets won't be hidden next time they open.

This does not need to be high security - it's just to stop accidental changes.  Any ideas?
0
Comment
Question by:andrewssd3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 37756575
This is the usual method: http://www.vbaexpress.com/kb/getarticle.php?kb_id=379
Essentially, every time you save, the sheets get hidden, the save is done, then the sheets get shown again. That way, the last save was always done with hidden sheets.
0
 
LVL 17

Author Comment

by:andrewssd3
ID: 37756610
Thanks Rory I'll give that a try.  I do have some issues with Worksheet_BeforeSave in my corporate environment (see this question which you participated in), but hopefully I'll be able to get this work.  I'll report back.
0
 
LVL 17

Author Comment

by:andrewssd3
ID: 37757235
Unfortunately, as I thought, it's not possible to change the visibility of worksheets from a Worksheet_BeforeSave routine that is initiated from VBA code (see the previous question I referred to).

Any other approaches to this that don't involve BeforeSave? Otherwise I'll award the points to you Rory as your solution would work well in a 'normal' environment.  Mine is skewed by having a document managment system that intercepts all Save and Open calls (the approach works when I disble the doc management add-in, but this is not an option for normal use).
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 85

Expert Comment

by:Rory Archibald
ID: 37757347
Could you use the beforesave to schedule a routine with OnTime to do the hide, save and reshow? Might work...
0
 
LVL 17

Accepted Solution

by:
andrewssd3 earned 0 total points
ID: 37757587
Interesting idea - I'll give it a try...
0
 
LVL 17

Author Closing Comment

by:andrewssd3
ID: 38094558
Thanks for the input on this - it gave me some interesting avenues to try, but I could not get anything to work as I wanted.  In the end I just had to take the risk that some savvy user would be able to get round the macro issue.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question