error 424 - Object Required

B

blb

I receive this error message sometimes while running the code below.
Out perhaps 1200 hits on this code it may error 2 or three times. Can
anyone see where the potential for error 424 would be?

Thanks!

Sub FreezePanes()
On Error GoTo ErrorHandler
If ActiveWindow.FreezePanes = False Then
MsgBox prompt:="The area to the left and top of the current
cell will be 'frozen'." & Chr(10) & _
"Select this menu option again to 'unfreeze'.",
Title:="CAP - Freeze Panes"
FreezeMenu.caption = "Un&freeze Panes"
Else
FreezeMenu.caption = "&Freeze Panes"
End If
ActiveWorkbook.Unprotect
ActiveWindow.FreezePanes = Not (ActiveWindow.FreezePanes)
ActiveWorkbook.Protect Windows:=True
Exit Sub
ErrorHandler:
Catch ThisWorkbook.Name, "FreezePanes"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top