Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Preventing "Protect Workbook"

Is there any way to disable the "Protect Workbook"
button in Excel 2007?? Just curious if there any ways
to prevent this option.

The reason I'm asking about this is because my workbook
contains lots of VBA code in which I set a sheet's "visible"
property to "xlVeryHidden" or "xlVisible". So, if someone
protects the workbook, the VBA code in the workbook
will crash if it encounters a line of code that attempts to
change any sheet's "visible" property.

thank u


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Preventing "Protect Workbook"

As far as I know you can not prevent protection, but you can test if the
workbook has been protected. It the workbook is protected, prompt user to
unprotect then run the macro again.

See below how to test:

Sub aaa()
If ThisWorkbook.ProtectStructure = True Then
msg = MsgBox("Protected")
Else
msg = MsgBox("Unprotected")
End If
End Sub

Regards,
Per

"Robert Crandal" skrev i meddelelsen
...
Is there any way to disable the "Protect Workbook"
button in Excel 2007?? Just curious if there any ways
to prevent this option.

The reason I'm asking about this is because my workbook
contains lots of VBA code in which I set a sheet's "visible"
property to "xlVeryHidden" or "xlVisible". So, if someone
protects the workbook, the VBA code in the workbook
will crash if it encounters a line of code that attempts to
change any sheet's "visible" property.

thank u


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Preventing "Protect Workbook"

Why not protect the workbook yourself, as part of your code, then you have
direct control over what the user can do.

The trade off is that you'll have to unprotect the workbook each time you
want to make your visibility changes, but this should make the whole process
much more robust.
--
If the post is helpful, please consider donating something to an animal
charity on my behalf.


"Robert Crandal" wrote:

Is there any way to disable the "Protect Workbook"
button in Excel 2007?? Just curious if there any ways
to prevent this option.

The reason I'm asking about this is because my workbook
contains lots of VBA code in which I set a sheet's "visible"
property to "xlVeryHidden" or "xlVisible". So, if someone
protects the workbook, the VBA code in the workbook
will crash if it encounters a line of code that attempts to
change any sheet's "visible" property.

thank u


.

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
Protect "Copy" and "Save As" changes to workbook Jason W Excel Discussion (Misc queries) 3 January 4th 09 01:13 AM
Preventing Auto_Open() runnng on vpc -Holding "Shift" doesn't work sirplus Excel Programming 0 November 12th 08 02:04 AM
Add "Protect ALL Sheets" that is the same as "Protect Sheet" KLLuoma Excel Worksheet Functions 0 July 27th 06 07:55 PM
".Protect userinterfaceonly:=True" & ".EnableSelection = xlUnlockedCells" not tabing STEVE BELL Excel Programming 1 February 23rd 06 01:39 AM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM


All times are GMT +1. The time now is 10:02 PM.

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"