Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dennis
 
Posts: n/a
Default Difference between Activesheet.unprotect

Using XL 2003


Can someone explain the differences between:

(A) ActiveSheet.Protect UserInterfaceOnly:=True
vs.
(B) ActiveSheet.Unprotect

In most cases where I have protected sheets, I can use (A) with no problems.

When attempting to use a macro to first delete then re-establish data
validation with different parameters (in a selected Range), I ran into a type
of " lost contact with X or Y error".

If I manually unprotected the sheet then ran the macro all was OK.

What I found was

Test Sub1()
ActiveSheet.Unprotect

..
.. "Data validation via VBA code"
..
..
..
..

ActiveSheet.Protect ' works
End Sub


Test Sub2()
ActiveSheet.Protect UserInterfaceOnly:=True
..
..
.. "Data validation via VBA code"
..
..
.. ' did not always work as mostly received
' error message mentioned above
End Sub

Any thoughts as to why?

Dennis
  #2   Report Post  
Jim Rech
 
Posts: n/a
Default

ActiveSheet.Unprotect allows users and macros free rein to make any kind of
change to a worksheet.

ActiveSheet.Protect UserInterfaceOnly:=True prevents users from making
changes to Locked cells directly through the UI, yet allows macros to make
(some of) those changes. This is mainly a convenience to developers so
everything they do via macros does not have to involve unprotecting and
re-protecting the sheet. As a practical matter UserInterfaceOnly:=True was
not implemented perfectly by MS so there are some changes a developer still
has to unprotect a sheet to make.

--
Jim
"Dennis" wrote in message
...
| Using XL 2003
|
|
| Can someone explain the differences between:
|
| (A) ActiveSheet.Protect UserInterfaceOnly:=True
| vs.
| (B) ActiveSheet.Unprotect
|
| In most cases where I have protected sheets, I can use (A) with no
problems.
|
| When attempting to use a macro to first delete then re-establish data
| validation with different parameters (in a selected Range), I ran into a
type
| of " lost contact with X or Y error".
|
| If I manually unprotected the sheet then ran the macro all was OK.
|
| What I found was
|
| Test Sub1()
| ActiveSheet.Unprotect
|
| ..
| .. "Data validation via VBA code"
| ..
| ..
| ..
| ..
|
| ActiveSheet.Protect ' works
| End Sub
|
|
| Test Sub2()
| ActiveSheet.Protect UserInterfaceOnly:=True
| ..
| ..
| .. "Data validation via VBA code"
| ..
| ..
| .. ' did not always work as mostly received
| ' error message mentioned above
| End Sub
|
| Any thoughts as to why?
|
| Dennis


  #3   Report Post  
Dennis
 
Posts: n/a
Default

Great and logical answer! My thought was that the "UserInterfaceOnly:" door
was "mainly" or "somwtimes"
Now I know what to do.

Thanks, Dennis

"Dennis" wrote:

Using XL 2003


Can someone explain the differences between:

(A) ActiveSheet.Protect UserInterfaceOnly:=True
vs.
(B) ActiveSheet.Unprotect

In most cases where I have protected sheets, I can use (A) with no problems.

When attempting to use a macro to first delete then re-establish data
validation with different parameters (in a selected Range), I ran into a type
of " lost contact with X or Y error".

If I manually unprotected the sheet then ran the macro all was OK.

What I found was

Test Sub1()
ActiveSheet.Unprotect

..
.. "Data validation via VBA code"
..
..
..
..

ActiveSheet.Protect ' works
End Sub


Test Sub2()
ActiveSheet.Protect UserInterfaceOnly:=True
..
..
.. "Data validation via VBA code"
..
..
.. ' did not always work as mostly received
' error message mentioned above
End Sub

Any thoughts as to why?

Dennis

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
Formula to find the working days difference between to dates? Mudgeman Excel Discussion (Misc queries) 2 May 15th 06 04:26 AM
Date difference Maxi Excel Worksheet Functions 7 July 28th 05 01:38 PM
charting a difference of 2 columns' w/o adding a difference column Wab Charts and Charting in Excel 4 July 27th 05 02:37 AM
Cell formats, and time difference Peter Kirk Excel Discussion (Misc queries) 1 May 25th 05 10:41 PM
How to get difference in hours Akhilesh Dalia Excel Worksheet Functions 6 April 23rd 05 06:41 AM


All times are GMT +1. The time now is 07:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"