Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with unprotecting worksheet in Excel 97

I am trying to unprotect a worksheet in some VB code I am
writing in Excel 97. The code works correctly in Excel
2000, however I get the following error in Excel 97:

Run-time error '1004'
Unprotect method of Worksheet class failed

Here is the code, I am getting the error on the 2nd line:

If ActiveSheet.ProtectContents = True Then
ActiveSheet.Unprotect
If CheckBox6.Value = True Then
....

Can anyone help I have been trying to figure this out for
weeks?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Help with unprotecting worksheet in Excel 97

Hi

If you are using a command button to run the code, Be sure to
set the Takefocusonclick property of the command button to false.
If that does not work, select a cell on the worksheet first like the code
below.

If ActiveSheet.ProtectContents = True Then
Cells(1, "a").Select
ActiveSheet.Unprotect
End If


It works for me.

HTH

Ken


"Steve Mikula" wrote in message
...
I am trying to unprotect a worksheet in some VB code I am
writing in Excel 97. The code works correctly in Excel
2000, however I get the following error in Excel 97:

Run-time error '1004'
Unprotect method of Worksheet class failed

Here is the code, I am getting the error on the 2nd line:

If ActiveSheet.ProtectContents = True Then
ActiveSheet.Unprotect
If CheckBox6.Value = True Then
....

Can anyone help I have been trying to figure this out for
weeks?




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.530 / Virus Database: 325 - Release Date: 22/10/2003


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
Unprotecting worksheet/workbook in Excel 2007 Steve Excel Worksheet Functions 2 September 19th 08 04:00 AM
Unprotecting a worksheet Jessica Excel Worksheet Functions 8 August 21st 08 06:43 PM
Unprotecting a Worksheet Anney Excel Worksheet Functions 7 August 4th 07 01:14 PM
Unprotecting a Protect Worksheet Ang Excel Worksheet Functions 1 January 11th 07 12:52 AM
unprotecting a worksheet Randy123 Excel Discussion (Misc queries) 1 August 8th 05 06:11 PM


All times are GMT +1. The time now is 03:15 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"