Solved

Excel 2007 VBA prevent workbook use with macros disabled

Posted on 2012-03-23
6
313 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
  • 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now