ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Password Protect Macro - Compile Error (https://www.excelbanter.com/excel-discussion-misc-queries/174004-password-protect-macro-compile-error.html)

Teddy-B

Password Protect Macro - Compile Error
 
Please help me to discover what is wrong with this excerpt from a macro that
I am writing to protect a sheet in my workbook with a password. I keep
getting the compile error message.
__________________________________________________
ActiveSheet.Protect Password:="PASS" DrawingObjects:=True,
Contents:=True, Scenarios:=True
ActiveWindow.SelectedSheets.Visible = False


Dave Peterson

Password Protect Macro - Compile Error
 
What line causes the error?

Those first two lines are really one logical line:

ActiveSheet.Protect Password:="PASS", DrawingObjects:=True, _
Contents:=True, Scenarios:=True

And you need a comma between each parameter (before drawingObjects)

The spacecharacter followed by an underscore is the continuation character in
VBA.

Teddy-B wrote:

Please help me to discover what is wrong with this excerpt from a macro that
I am writing to protect a sheet in my workbook with a password. I keep
getting the compile error message.
__________________________________________________
ActiveSheet.Protect Password:="PASS" DrawingObjects:=True,
Contents:=True, Scenarios:=True
ActiveWindow.SelectedSheets.Visible = False


--

Dave Peterson


All times are GMT +1. The time now is 07:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com