ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   protect workbook (https://www.excelbanter.com/excel-programming/400448-protect-workbook.html)

eugene

protect workbook
 
Hi,

I would like to protect the structure of a workbook.

I have tried

ActiveWorkbook.Protect Password:=pword, Structu=False
ActiveWorkbook.Protect (pword, True)

(where pword is a variable defined earlier)
and various other combinations.
I get a compile error in all cases - "Expected: ="

What am I doing wrong?

Eugene



eugene

protect workbook
 
Problem solved.

My password variable was a number which was not being accepted by
Activeworkbook.Protect. Changed it to a string using Cstr(pword) and it works.

Strange thing is that I used the same logic and commands to protect the
sheets in the workbook. ActiveSheet.Protect Password:=pword works when the
pword is an integer or other number.

Quite quirky if you ask me.

Eugene



"eugene" wrote:

Hi,

I would like to protect the structure of a workbook.

I have tried

ActiveWorkbook.Protect Password:=pword, Structu=False
ActiveWorkbook.Protect (pword, True)

(where pword is a variable defined earlier)
and various other combinations.
I get a compile error in all cases - "Expected: ="

What am I doing wrong?

Eugene




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

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