PDA

View Full Version : Code needed for popup message box asking for password to open & use workbook



ads_3131
10-20-2008, 04:27 AM
Hello, I am sort of new to this & just wondering if anyone can help me with a code to protect my workbook, thanks

mdmackillop
10-20-2008, 05:32 AM
Welcome to VBAX
Check out Password Protection in Excel Help to start with. If you have specific requirements, please let us know.

CreganTur
10-20-2008, 05:34 AM
Welcome to the forum- always good to have new members!



Hello, I am sort of new to this & just wondering if anyone can help me with a code to protect my workbook, thanks

Excel has some built in protection capabilities that should help you out tremendously.

If you want to password protect your workbook then you need to click Tools -> Options -> Security (tab). There you have the option to setup a Password to Open and a Password to Modify.

If you want to keep Users from being able to make changes to the workbook you also need to look at Tools -> Protection. There are numerous protection options there, and you can customize them so that you create unique rules on what Users can and can't do with the workbook (or individual sheets).

HTH:thumb

ads_3131
10-20-2008, 08:19 AM
Hello, i am aware of Excels built in security features but i am looking for alternitives? any suggestions , btw thanks for quick response

Krishna Kumar
10-20-2008, 09:07 AM
Hi,

Download sample workbook from here (http://www.ozgrid.com/forum/showthread.php?t=73749)

georgiboy
10-20-2008, 10:06 AM
Im not sure how technical you want but you could use something along these lines?

Private Sub Workbook_Open()

x = InputBox("Please enter password", "Password needed!")
If x <> "Password" Then ActiveWorkbook.Close False

End Sub

in the workbook code window

Hope this helps

ads_3131
10-21-2008, 12:27 AM
Thanks works great :D

mdmackillop
10-21-2008, 12:34 AM
Be aware that holding down Shift while opening a workbook disables this macro. Check out forcing enabling of macros in the KB

davidw
11-12-2008, 08:02 AM
I was looking for something to protect my data file. I made it a shared file so I could use the history. Your code works great. I have the shared data file (which is now protected by the password) and I have another program that accesses the data file and compiles data for reporting purposes. I need to know how I can open the data file (now password protected) using vba in the other program.