View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default Confused, again! Object variable not set?

Testing methodoligy would suggest try commenting out the first affected line.
If the next line gives the same error, then it would suggest the cause that
others here have indicated. If it is a different error (as obviously to
perform the requested function the protection must be turned off to do the
next step) then there is definetly a problem with the line indicated and it
is other than that suggested by others here.


"davegb" wrote:

This code is on the worksheet module. It hides the commandbar that is
unique to this sheet when the sheet is deactivated and erases the
commandbar name from the worksheet so that XL doesn't try to hide the
toolbar when the workbook is closed.

Private Sub Worksheet_deActivate()
Application.CommandBars("Abuse").Visible = False

With wksMacRec
.Unprotect Password:=PWORD<----ERROR
.Range("E2").Value = ""
.Protect Password:=PWORD
End With
'ActiveWorkbook.Worksheets("Macro Records").Range("E2").Value = ""
End Sub

I'm getting an "object variable or with block variable not set" error.
The password in set as a public constant in another module in this same
workbook. So whatzzup?
Thanks as always.