Re: Unable to Lock a Range

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Hank Scorpio (ApolloXVIII_at_Hates.Spam)
Date: 07/10/04


Date: Sat, 10 Jul 2004 22:30:50 +1000

On Sat, 10 Jul 2004 12:55:18 +0100, "Stuart" <sg_booth@hotmail.com>
wrote:

>With ActiveWorkbook.Sheets("Contract Master Order")
> .Range("A1:N70").Locked = True
> .Protect Password:="SGB"
> .EnableSelection = xlUnlockedCells
>End With
>
>The Locked statement results in Error 1004,
>Unable to set the Locked property of the Range class.

>I've some embedded ActiveX textboxes in the range in question
>.......is that the problem?

I doubt it. I don't seem to be encountering that problem in a test
workbook with embedded ActiveX controls, and I haven't seen it before.

This is probably a rather obvious thing to ask, but what the hey...
are you sure that the *** is unprotected at the time that you
execute the

 .Range("A1:N70").Locked = True

line? If it's not (perhaps from having run the procedure previously),
you'll get a 1004 error. If that's all it is, add an extra line
unprotecting the *** before you change the Locked property. (Do an
IF test to make sure that the *** is in fact protected before
executing the Unprotect one.)

>If so, can I remove the controls (but retain the user's text) and
>then protect the *** and book, please?

---------------------------------------------------------
Hank Scorpio
scorpionet who hates spam is at iprimus.com.au (You know what to do.)
* Please keep all replies in this Newsgroup. Thanks! *


Quantcast