Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Problems using Protect/Unprotect a worksheet

Greetings,

I am having problems toggling the Protect mode on a spreadsheet. I ca
Protect/Unprotect from the Tools menu.

The workbook is not protected nor is it shared.

When I execute my macro I get the following error message:

Run-time error '1004':

Unprotect method of Worksheet class failed


The message occurs when I execute either of the following:

- Sheets("SheetName").Unprotect
- Worksheets("SheetName").Unprotect

The macro is executed by clicking on a button on the worksheet.

I am running Excel 97.

Thanks (TIA)
Gar

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel VBA - Problems using Protect/Unprotect a worksheet

Change the TakeFocusOnClick property of the commandbutton to false. This
should fix it.

Problem fixed in xl2000 and later.

--
Regards,
Tom Ogilvy


Gary Richie wrote in message
...
Greetings,

I am having problems toggling the Protect mode on a spreadsheet. I can
Protect/Unprotect from the Tools menu.

The workbook is not protected nor is it shared.

When I execute my macro I get the following error message:

Run-time error '1004':

Unprotect method of Worksheet class failed


The message occurs when I execute either of the following:

- Sheets("SheetName").Unprotect
- Worksheets("SheetName").Unprotect

The macro is executed by clicking on a button on the worksheet.

I am running Excel 97.

Thanks (TIA)
Gary


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Excel VBA - Problems using Protect/Unprotect a worksheet

On Thu, 5 Feb 2004 21:14:54 -0600, Gary Richie
wrote:

Add the command Activecell.Select before you try the unprotect method.
There's a known issue with command buttons taking the focus in Excel
97 which often causes the kind of problem you're referring to.

I am having problems toggling the Protect mode on a spreadsheet. I can
Protect/Unprotect from the Tools menu.

The workbook is not protected nor is it shared.

When I execute my macro I get the following error message:

Run-time error '1004':

Unprotect method of Worksheet class failed

The message occurs when I execute either of the following:

- Sheets("SheetName").Unprotect
- Worksheets("SheetName").Unprotect

The macro is executed by clicking on a button on the worksheet.

I am running Excel 97.


---------------------------------------------------------
Hank Scorpio
scorpionet who hates spam is at iprimus.com.au (You know what to do.)
* Please keep all replies in this Newsgroup. Thanks! *
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, unprotect Pyrite Excel Discussion (Misc queries) 0 August 15th 08 03:18 PM
Protect/ unprotect worksheet cc Excel Discussion (Misc queries) 0 October 19th 07 09:27 PM
How do I unprotect a protected worksheet that has passwrod protect Iain A C T Excel Discussion (Misc queries) 9 September 28th 05 05:38 AM
unprotect/protect grouped worksheets in excel mcwhirter Setting up and Configuration of Excel 1 August 8th 05 01:21 AM
Protect/Unprotect Worksheet djn Excel Discussion (Misc queries) 1 May 12th 05 11:27 PM


All times are GMT +1. The time now is 06:06 PM.

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"