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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,223,099
Messages
6,170,114
Members
452,302
Latest member
TaMere

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