View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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/