Password protect workbook when opened. On failed attempt close, send email and delete workbook.

camerong

New Member
Joined
May 9, 2023
Messages
42
Office Version
  1. 2016
Platform
  1. Windows
Hi guys,

Not sure where to start with this one, any help is greatly appreciated.

I am after a code that would run as soon as the workbook is opened. I would like it to first check the "Device name" and compare it to a list of names in the code which are allowed to open the workbook. If the "Device name" is on the list then it opens fine without any password prompt. If the "Device name" is not on the list then I would like it to prompt the user for a password (set in the code). If the user inputs the correct password, then the workbook opens fully. If the user inputs the incorrect password, then the Workbook shuts down, is deleted (would be great if it was permanently deleted, not just put in recycling bin) and an email is sent to a specific email address (stipulated in the code).

I am after this to try and protect company intellectual property.
 
Hi Sijpie,

I've changed the workbook code and device names, then tried reopening it. It reopens and doesn't prompt for a password, however it has all the other worksheets hidden except the one specified in the code. VBA seems accessible, its just the worksheets that aren't accessible / visible.
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,215,109
Messages
6,123,137
Members
449,098
Latest member
Doanvanhieu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top