#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 141
Default Locking A sheet

I am using a Custom Button to lock/unlock a sheet

If ActiveSheet.ProtectContents = True Then
ActiveSheet.Unprotect

With Application.CommandBars.ActionControl
.Caption = "Protect Sheet"
End With
Exit Sub
End If

With Application.CommandBars.ActionControl
.Caption = "Un Protect Sheet"
End With
ActiveSheet.Protect

if the sheet is unlocked the code will work and change the button text but
when I go to relock the sheet the line of code to change the caption to
unlock sheet errors out with

Object Variable or With block variable not set

why does it work outsied the if statement and not inside

thanks
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
Auto Rename Excel Sheets in Workbook Kulin Shah Excel Worksheet Functions 12 December 25th 06 03:27 PM
Cell References [email protected] Excel Discussion (Misc queries) 2 November 15th 06 11:37 PM
Named Ranges Epinn Excel Worksheet Functions 23 October 16th 06 07:27 AM
Asked previously...can this not be done in excel simonsmith Excel Discussion (Misc queries) 2 May 16th 06 11:50 PM
Using a relative SHEET reference for source data in a chart James Charts and Charting in Excel 6 August 16th 05 05:07 PM


All times are GMT +1. The time now is 11:44 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"