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

Hi,

I have a file that is opened by a user and a macro is run to protect it so
when the file is sent out to another user, none of the cells can be selected.
The issue I am having is the macro protects the workbook but when the user
opens the workbook in Read only mode, he/she is still able to unprotect it
with out using a password. I would like the unprotect button in excel 2007 to
be grayed out when the user opens the file in read Only mode. It was my
understanding that if wrterespassword was used that the user would be
prompted to open in read only or enter the password. If the user selects read
only, they should not be able to unprotect teh workbook. Please see my code
below. What am I missing here? Any assistance is greatly appreciated.

ActiveWorkbook.Protect Password:="Password", structu=True,
Windows:=False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
ActiveSheet.EnableSelection = xlNoSelection

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileFormat:=xlNormal, ReadOnlyRecommended:=True, _
WriteResPassword:="Password"
--
Thank you

Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Protect a Workbook

You missed the Password on the sheet protect. The workbook and worksheet
protect are two different things.

ActiveSheet.Protect Password:="password",DrawingObjects:=True, _
Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
ActiveSheet.EnableSelection = xlNoSelection

--
If this helps, please remember to click yes.


"Dave" wrote:

Hi,

I have a file that is opened by a user and a macro is run to protect it so
when the file is sent out to another user, none of the cells can be selected.
The issue I am having is the macro protects the workbook but when the user
opens the workbook in Read only mode, he/she is still able to unprotect it
with out using a password. I would like the unprotect button in excel 2007 to
be grayed out when the user opens the file in read Only mode. It was my
understanding that if wrterespassword was used that the user would be
prompted to open in read only or enter the password. If the user selects read
only, they should not be able to unprotect teh workbook. Please see my code
below. What am I missing here? Any assistance is greatly appreciated.

ActiveWorkbook.Protect Password:="Password", structu=True,
Windows:=False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
ActiveSheet.EnableSelection = xlNoSelection

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileFormat:=xlNormal, ReadOnlyRecommended:=True, _
WriteResPassword:="Password"
--
Thank you

Dave

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,388
Default Protect a Workbook

thanks, I knew I was missing something. It worked

--
Thank you

Dave


"Paul C" wrote:

You missed the Password on the sheet protect. The workbook and worksheet
protect are two different things.

ActiveSheet.Protect Password:="password",DrawingObjects:=True, _
Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
ActiveSheet.EnableSelection = xlNoSelection

--
If this helps, please remember to click yes.


"Dave" wrote:

Hi,

I have a file that is opened by a user and a macro is run to protect it so
when the file is sent out to another user, none of the cells can be selected.
The issue I am having is the macro protects the workbook but when the user
opens the workbook in Read only mode, he/she is still able to unprotect it
with out using a password. I would like the unprotect button in excel 2007 to
be grayed out when the user opens the file in read Only mode. It was my
understanding that if wrterespassword was used that the user would be
prompted to open in read only or enter the password. If the user selects read
only, they should not be able to unprotect teh workbook. Please see my code
below. What am I missing here? Any assistance is greatly appreciated.

ActiveWorkbook.Protect Password:="Password", structu=True,
Windows:=False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
ActiveSheet.EnableSelection = xlNoSelection

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileFormat:=xlNormal, ReadOnlyRecommended:=True, _
WriteResPassword:="Password"
--
Thank you

Dave

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Protect a Workbook

You protected the workbook's structure using a password. That means that the
user can't rearrange sheets (or add or delete more sheets) without unprotecting
the workbook's structure.

But you protected the activesheet without a password. That means that the user
can change values to any of the unlocked cells in that protected sheet. And
they only have to unprotect the sheet to be able to change any of the cells
(unlocked or locked). And since you didn't provide a password, it's pretty
simple to do.

Using:

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, password:="hi there",
_
Scenarios:=True, AllowSorting:=True, AllowFiltering:=True

would make it slightly more difficult to unprotect that sheet. But there are
lots of ways to break this password.

And saving the workbook with WriteResPassword means that the user can still open
the workbook in readonly mode. Then make as many changes as they want (and that
your other protection settings allow) and save as a new name.

All of these levels of protection are independent of the others--as long as the
user can open the workbook.

=====
Just a note--the workbook protection (tools|Protection|protect sheet and
tools|Protection|protect workbook are both easily broken. Don't trust them to
keep the dedicated from your intellectual property.

The password to open is more difficult to break--but there are lots of sites on
the internet that will make it easy if the person has a few bucks and really
wants to open your file.



Dave wrote:

Hi,

I have a file that is opened by a user and a macro is run to protect it so
when the file is sent out to another user, none of the cells can be selected.
The issue I am having is the macro protects the workbook but when the user
opens the workbook in Read only mode, he/she is still able to unprotect it
with out using a password. I would like the unprotect button in excel 2007 to
be grayed out when the user opens the file in read Only mode. It was my
understanding that if wrterespassword was used that the user would be
prompted to open in read only or enter the password. If the user selects read
only, they should not be able to unprotect teh workbook. Please see my code
below. What am I missing here? Any assistance is greatly appreciated.

ActiveWorkbook.Protect Password:="Password", structu=True,
Windows:=False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
ActiveSheet.EnableSelection = xlNoSelection

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileFormat:=xlNormal, ReadOnlyRecommended:=True, _
WriteResPassword:="Password"
--
Thank you

Dave


--

Dave Peterson
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
Can protect worksheet then workbook but not Protect and Share in code [email protected] Excel Programming 7 January 16th 17 07:01 AM
workbook protect helpme Excel Programming 3 July 14th 07 01:09 PM
Protect Workbook Vs Protect Sheet Poor_pakistani New Users to Excel 4 May 25th 06 02:06 PM
Disable Tools, Protect, Protect Workbook Paul Moles Excel Programming 1 September 5th 05 03:37 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Excel Programming 9 July 25th 05 12:44 PM


All times are GMT +1. The time now is 02:11 AM.

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"