Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Unprotect worksheet error

Hi All,

I have a worksheet which is protected when the user first opens it, then
when they press a button the macro unprotects the sheet, does some things,
then re-protects the sheet. The protection is there simply to stop people
accidentally mucking around with formulas etc so it doesn't matter that there
is no password.

I am almost finished developing this and have struck a snag - the unprotect
function sends up an error when I press the macro button. If the sheet is
unprotected when I push the button everything works fine, if it is protected
I get the error message and using debug points me to the unprotect piece of
code.

I have tried;

ActiveSheet.Unprotect - didn't work

Worksheets("Sheet1").Activate
ActiveSheet.Unprotect - didn't work

Has anyone got any other ideas? Or even know why this might happen? Could
it be that the code was originally written in a new version of excel and I'm
using 97?

The error message is;

Runtime Error "1004" Unprotect method of worksheet class failed

Any help would be most appreciated.

Fiona

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Unprotect worksheet error

It is a bug in Excel 97. Change the TakeFocusOnClick property of the
commandbutton to false and it should work.

--
Regards,
Tom Ogilvy

"fiona" wrote in message
...
Hi All,

I have a worksheet which is protected when the user first opens it, then
when they press a button the macro unprotects the sheet, does some things,
then re-protects the sheet. The protection is there simply to stop people
accidentally mucking around with formulas etc so it doesn't matter that

there
is no password.

I am almost finished developing this and have struck a snag - the

unprotect
function sends up an error when I press the macro button. If the sheet is
unprotected when I push the button everything works fine, if it is

protected
I get the error message and using debug points me to the unprotect piece

of
code.

I have tried;

ActiveSheet.Unprotect - didn't work

Worksheets("Sheet1").Activate
ActiveSheet.Unprotect - didn't work

Has anyone got any other ideas? Or even know why this might happen?

Could
it be that the code was originally written in a new version of excel and

I'm
using 97?

The error message is;

Runtime Error "1004" Unprotect method of worksheet class failed

Any help would be most appreciated.

Fiona



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Unprotect worksheet error

Thanks Tom,

That worked perfectly. Will the end users (who knows a little of VBA) have
to change the property back? They are overseas so I need to tell them when I
send it to them.

Fiona

"Tom Ogilvy" wrote:

It is a bug in Excel 97. Change the TakeFocusOnClick property of the
commandbutton to false and it should work.

--
Regards,
Tom Ogilvy


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Unprotect worksheet error

Once set, it should remain set.

--
Regards,
Tom Ogilvy

"fiona" wrote in message
...
Thanks Tom,

That worked perfectly. Will the end users (who knows a little of VBA)

have
to change the property back? They are overseas so I need to tell them

when I
send it to them.

Fiona

"Tom Ogilvy" wrote:

It is a bug in Excel 97. Change the TakeFocusOnClick property of the
commandbutton to false and it should work.

--
Regards,
Tom Ogilvy




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
400 Error in Unprotect/Protect Macro Youngergirl44 Excel Discussion (Misc queries) 1 September 23rd 08 01:29 PM
unprotect a worksheet shelly Excel Worksheet Functions 3 December 19th 07 12:37 AM
Unprotect Worksheet. xoom3 Excel Discussion (Misc queries) 4 July 14th 06 10:00 PM
Unprotect worksheet via VBA Mike Echo Excel Worksheet Functions 2 March 19th 06 04:52 AM
Unprotect method run-time error Rohit Thomas Excel Programming 0 July 8th 03 07:32 PM


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

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

About Us

"It's about Microsoft Excel"