Disallow workbook editing unless Enable Content is clicked - excel

I'm setting up a shared Excel spreadsheet with macros, but I don't want to let anyone edit the document at all until they've clicked the "Enable Content" in the SECURITY WARNING bar at the top.
How can I "protect" the workbook like that?

Set up the workbook to run a macro before the file is saved (workbook.beforesave). In that routine, set all sheets to xlVeryHidden, except for one sheet where you explain that the user needs to enable macros. You could even have a screenshot showing what they need to click.
When macros are enabled, the workbook_open event can unhide all sheets you want to show.
Protect the VBA project with a password.
Someone with very malicious intent and advanced coding skills will probably be able to find a way to circumvent this setup, but it should work well in a business environment where people just want to get their work done.

Related

Need to disable copy/paste command on excel 2007 across different users

I need to disable the copy/paste in excel 2007. The excel file will be sent to different users so i need a solution where copy/paste is disabled for all users.
I have searched the web but everyone has asked to enable the macros but the problem with that is i will have to enable the macros for every user first before restricting them from copy/pasting.
So looking for a solution where i can write some vba code on sheet to restrict all users from copy/pasting without enabling macros.
Thanks.
Lock the Cells with the Protection Option of Excel manually or lock them programmatically.
Example:
'Range Lock
Worksheets("Sheet1").Range("A1:G37").Locked = True
'Sheet Lock
Worksheets("Sheet1").Protect
EDIT:
Just saw ur new comment, there is no option to use VBA code to block ONLY copy/pasting without allowing Macros in ur Workbook.
You don't need VBA for this.
Go to the review tab
Select protect sheet
Protect with password and take away the ✓ (there should only be one)

Password to protect macro used on the change event in excel

I know that a vba macro can be password protected. I was wondering if the same could be applied to an event change macro? If yes then how would you go about it.
"To protect your code, open the Excel Workbook and go to Tools>Macro>Visual Basic Editor (Alt+F11). Now, from within the VBE go to Tools>VBAProject Properties and then click the Protection page tab and then check "Lock project from viewing" and then enter your password and again to confirm it. After doing this you must save, close & reopen the Workbook for the protection to take effect."
Source: http://www.ozgrid.com/VBA/protect-vba-code.htm
This was an easy google, I reccomend you look online before asking on Stack Overflow, these simple questions are generally not well received.
If your question is about protecting a specific part of your code, and not the other parts of the code, then it can't be done as far as I know.

preventing Excel app from being emailed

I have employees that use a macro/external data enabled Excel file. One of the worksheets in this file contains proprietary data, that is populated from an external data source ODBC connection. This proprietary worksheet is always hidden from the user, because it just serves as a Vlookup-function data-source
I want to prevent my employees from accidentally emailing this Excel file, because I don’t want the hidden worksheet data to be available to non-employees
Please advise if there is anything I can do prevent the email recipient from being able to view the data that is in the hidden worksheet, if the app is accidentally emailed to them.
Are any of the following ideas feasible?:
Password protecting the hidden worksheet, yet, not preventing the Vlookup function from the other worksheet from functioning?
Imbedding something into the app that resembles a virus, to cause all email servers to block the attachment.
Creating a macro that deletes the data from the hidden worksheet when the app is closed
Imbedding large images into the app to make it too large to email, but yet won’t affect the performance.
Please advise, thank you very much in advance, Nathaniel
In regards to number 3, there is a setting like this in the Connection Properties. It's "Remove Data from the external data range before saving the workbook." I'm not looking at XL 2003, but it's nested under the "Refresh Data When Opening the File" option. As others have said, this isn't foolproof, but it might help meet your requirements.
I don't think you can fundamentally prevent your workbook to be sent around. Password-protecting the sheet would be of little help, as it is fairly easy to bypass. The safest approach to protect your proprietary data from prying eyes would be to not have it in the worksheet itself, retrieve it dynamically by prompting the user for some credentials, and never save it in a worksheet.
You can hide the sheet from the developer tab of excel. To do this, follow the steps below
Open the excel
Press Alt + F11
Here you can see the list of sheets on your excel file
Select the sheet that you want to hide
When you select the sheet you can see the properties of the particular sheet below
Set the visibility property to ‘2 – xlSheetVeryHidden’
Now right click on the sheet and select VBAProject – Project Properties
Navigate to the Protection tab and check ‘Lock project for viewing’
Set a password
Sheets hidden in this way cannot be un hidden unless one has access to the VBA Project (but this is now password protected). The sheet can be seen only if you know the password.

How to permanently allow macro for a trusted worksheet?

I've created a worksheet which is shared amongst my colleagues with a real simply macro to show/hide rows but everytime either I or one of my colleagues opens it they get prompted to Allow marco - is there anyway for them to permantly allow this macro?
You'll want to digitally sign the project. Microsoft's information about how to do that is here: http://office.microsoft.com/en-us/excel-help/digitally-sign-a-macro-project-HA001231781.aspx
You need to change a setting in Macro Security within Excel so that your colleagues don't have to respond to a dialog box every time. Be advised, though, that when you allow macro code to run automatically, this can unsuspectingly open you up to malicious code in other Excel workbooks.
The location of the settings for Macro Security is different from versions 2003 and 2007 of Excel. In 2003 and previous, I believe the setting is visible in Tools > Macros > Macro Security. From there, you would change the security level to low. In Excel 2007 (and probably 2010), the setting is visible in the Developer tab on the ribbon (which you might have to make visible by toggling a checkbox in Excel Options). From the Developer tab, click Macro Security and chose Enable All Macros.
The above is the simplest way for your colleagues to make a change to their system, but a better way, as others suggest, would be to digitaly sign your own work so that your colleagues don't have to open a potential security hole on their own system.

Macro Edit/View Protection

I have written a VBA macro to do some stuff in Excel, and I want to know if the following is possible.
How do I protect a Macro so that no matter who uses the spreadsheet, they cannot edit the code? The protection needs to be strong enough that even if they press ALT + F11 and pull up the macro, the Edit button options need to be greyed out, even if the macro has been selected.
Also is it possible to stop a user from even seeing the code?
I think the easiest way is just to protect the workbook code. VBA Project properties -> Protection -> Lock project for viewing. You will need to specify a password.
It's not world-class protection, but it will stop the average user editing the code.

Resources