LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Why Can't Unprotect and write value into worksheet before close.

I don't see any reason to do it except that you are closing the workbook in
the beforeclose event which would trigger another beforeclose event and
possibly so forth.

--
Regards,
Tom Ogilvy



"EdgeOfCity" wrote in message
...
worksheets("sheet2") has been protected from "Tool" menu with password
"test".
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i As Integer
With Worksheets("sheet2")
.Activate
.Unprotect Password:="test"
On Error Resume Next
.Cells(4, 4) = "HI"
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True,
Password:="test"
End With
ActiveWorkbook.Close SaveChanges:=True
End Sub

the question is that why should add "On error resume next"?




 
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
Unprotect a worksheet Mayumdwl Excel Worksheet Functions 1 April 21st 09 12:30 AM
unprotect a write protected file suzzyq Excel Discussion (Misc queries) 2 June 8th 08 08:22 PM
unprotect a worksheet shelly Excel Worksheet Functions 3 December 19th 07 12:37 AM
Unprotect a worksheet Bryan Excel Discussion (Misc queries) 11 April 14th 06 02:42 AM
Unprotect Worksheet Phil Perry Excel Programming 0 July 10th 03 01:22 PM


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