View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Unable to Lock a Range

You sure that the worksheet was unprotected when you started?

Maybe checking first would be beneficial.

Option Explicit
Sub testme()

With ActiveWorkbook.Sheets("Contract Master Order")

If .ProtectContents = True _
Or .ProtectDrawingObjects = True _
Or .ProtectScenarios = True Then
'it's protected
.Unprotect Password:="SGB"
End If

.Range("A1:N70").Locked = True
.Protect Password:="SGB"
.EnableSelection = xlUnlockedCells

End With
End Sub



Stuart wrote:

Here's the code:

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?

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

Regards.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.716 / Virus Database: 472 - Release Date: 05/07/2004


--

Dave Peterson