XL98: Protect Method Password Is Not Applied to Worksheet (184100)
The information in this article applies to:
- Microsoft Excel 98 Macintosh Edition
This article was previously published under Q184100 SYMPTOMS
When you use the Protect method in a Visual Basic for Applications macro to
apply password protection to a worksheet, Microsoft Excel does not apply
the password to the worksheet.
CAUSE
This problem occurs when both of the following conditions are true:
- You use a second ActiveSheet.Protect command that specifies a password
in the macro.
-and-
- You set all the arguments (Contents, Scenarios, and DrawingObjects) for
the second ActiveSheet.Protect command to True.
NOTE: Microsoft Excel may not apply password protection depending on the
values of the arguments for the Protection statement. In some cases,
Microsoft Excel applies worksheet protection but does not apply a password
even if you specify a password in the macro.
WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
To work around this problem, use either of the following methods.
Method 1
Use the ActiveSheet.Protect command only once and supply all the arguments,
including the password. For example, use the following macro:
Sub ProtectSheet()
ActiveSheet.Protect password:="pw", Contents:=True, _
Scenarios:=False, DrawingObjects:=True, UserInterfaceOnly:=True
End Sub
Method 2
Set one of the Protect method arguments to False. To do this, use either of
the following methods:
- If the macro is recorded, clear one of the following check
boxes: Contents, Objects or Scenarios.
-or-
- If the macro is manually typed, use the following syntax
Sub ProtectSheet()
ActiveSheet.Protect password:="pw", Contents:=True, _
Scenarios:=False, DrawingObjects:=True, _
UserInterfaceOnly:=True
End Sub
to set either Contents, Scenarios, or DrawingObjects to False.
STATUS
Microsoft has confirmed this to be a problem with the products listed at
the beginning of this article.
REFERENCES
For more information about protecting information, from the Visual Basic
Editor, click the Office Assistant, type Protect click Search, and then
click to view "Protect Method."
NOTE: If the Assistant is hidden, click the Office Assistant button on the
Standard toolbar. If the Assistant is not able to answer your query, please
see the following article in the Microsoft Knowledge Base:
176476 OFF: Office Assistant Not Answering Visual Basic Questions
Modification Type: | Minor | Last Reviewed: | 10/10/2006 |
---|
Keywords: | kbbug kbdtacode kbpending kbProgramming KB184100 |
---|
|