Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Workbook is protected, even after manual + VBA unprotect 1

Status
Not open for further replies.

krinid

Programmer
Jun 10, 2003
356
CA
I ran some code I found in one of the threads (don't remember which one) that protects a workbook (most likely the equivalent of
Code:
ThisWorkbook.Protect ("test")
)

However, now when I open my workbook, it prompts for a PWD (fortunately, I remember that I used "test"). When I go to Tools/Protection, the book isn't protected. Even executing a
Code:
ThisWorkbook.Unprotect ("test")
doesn't solve it. Opening the book again prompts for the PWD.

I'd like to remove the protection from the workbook entirely.

Any know what the problem is?
 
Hi Krinid,
Excel has different types of protection:
1. opening file - password required to open file (sample code: Workbooks(1).Password = "x"),
2. changing file - password required to open r/w (sample code: Workbooks(x).WritePassword = "x"),
3. workbook protection (sample code: Workbook(1).Protect Password:="x", Structure:=True),
4. worksheet protection (sample code: Worksheets(1).Protect Password="x", DrawingObjects:=True, Contents:=True).
In case of (1) or (2) type of protection, excel prompts for password, those passwords can be removed by saving again without password, or Tools>Options>Protection tab (at least in xp).
All passwords can be removed in VBA by setting ...Password="" or Password=:"" in appropriate code (1-4).

combo

 
combo,
It was password protection type 1 (as listed above) I was encountering. Problem was, I didn't know type 1 existed, and was trying to eliminate the password using the methods for type 3. You've straightened me out on this topic--cheers and a star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top