VBA code for work book open event

Caze982

Board Regular
Joined
May 10, 2015
Messages
77
Hi everyone

I have workbook that i want to protect with a password and when it opens ask for the password. i want to use vba code. Does anyone know how to do that?

Sincerly
Christian
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You can password protect by protecting your workbook. (Review Tab > Protect Workbook)

Using VBA is possible but if people don't have macros enabled then the code won't run. Only way around that, if VBA MUST be used is to hide all the sheets until they click a button which ensures they can only view the workbook if macros are enabled.
 
Upvote 0
You can password protect by protecting your workbook. (Review Tab > Protect Workbook)

Using VBA is possible but if people don't have macros enabled then the code won't run. Only way around that, if VBA MUST be used is to hide all the sheets until they click a button which ensures they can only view the workbook if macros are enabled.

Thank you for your answer. I would like to use vba code, do you know how to do that?

Sincerly
Christian
 
Upvote 0
May we ask why? It's far less secure than setting a password to open the workbook by encrypting it.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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