Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Locked/Protect in Workbook_open not working in X2002

I created and used the following code in Excel 2000 with
no problems:

Private Sub Workbook_Open()

If Worksheets("BudgetForm").Protect = False Then
Worksheets("BudgetForm").Range("g16:g19").Locked = False
Worksheets("BudgetForm").Range("h16:h19").Locked = False
Worksheets("BudgetForm").Range("h25:h29").Locked = False
Worksheets("BudgetForm").Range("g31:g47").Locked = False
Worksheets("BudgetForm").Protect Contents:=True,
Objects:=True, Scenarios:=True
End If
ActiveWorkbook.Protect Structu=True, Windows:=False
Range("A1").Select
End Sub

But since I have upgraded to Excel 2002, I get an error
message when opening the workbook. The highlighted code is
the second line.

Any help is appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Locked/Protect in Workbook_open not working in X2002

Hi Lydia,

The fact that this code worked in Excel 2000 was a bug. The Protect
method of the Worksheet object can't be used to determine whether a
worksheet is protected or not. There are specific properties to query for
each type of worksheet protection applied, for example:

If Worksheets("BudgetForm").ProtectContents = False Then

End If

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Lydia" wrote in message
...
I created and used the following code in Excel 2000 with
no problems:

Private Sub Workbook_Open()

If Worksheets("BudgetForm").Protect = False Then
Worksheets("BudgetForm").Range("g16:g19").Locked = False
Worksheets("BudgetForm").Range("h16:h19").Locked = False
Worksheets("BudgetForm").Range("h25:h29").Locked = False
Worksheets("BudgetForm").Range("g31:g47").Locked = False
Worksheets("BudgetForm").Protect Contents:=True,
Objects:=True, Scenarios:=True
End If
ActiveWorkbook.Protect Structu=True, Windows:=False
Range("A1").Select
End Sub

But since I have upgraded to Excel 2002, I get an error
message when opening the workbook. The highlighted code is
the second line.

Any help is appreciated!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protect sheet unchecking "Select locked cells" has undesiredresults wal Excel Discussion (Misc queries) 1 September 1st 08 03:28 PM
protect formulas in locked cells from changing if data is moved Cleve Excel Discussion (Misc queries) 3 July 24th 08 03:12 PM
Macros to protect worksheet and prevent locked cell selection Excel Enthusiastic[_2_] Excel Discussion (Misc queries) 1 April 23rd 07 09:44 AM
Locked cells with Protect Sheet. ness Excel Discussion (Misc queries) 2 June 13th 06 07:48 PM
Workbook_Open not working Sheena N via OfficeKB.com Excel Discussion (Misc queries) 4 May 6th 05 01:31 AM


All times are GMT +1. The time now is 04:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"