Click here to Skip to main content
16,016,712 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear friends

how to protect excel workbook in vb.net or vb6.0 thru code.
excel workbook not excel sheet
thanks...
Posted
Comments
Sinisa Hajnal 29-Jan-15 5:06am    
What do you mean? You want to lock the workbook and disable users ability to turn it back on?

1 solution

If you wish to protect the workbook from being opened and/or read-only then in the Save As dialog box, click the Tools drop-down to the left of the Save button and specify the password for opening/allowing modification.

This can be achieved in VBA using something like the following:

CSS
ActiveWorkbook.SaveAs Filename:="C:\Users\John Mc Hale\Documents\Protect.xls" _
        , FileFormat:=xlExcel8, Password:="password", WriteResPassword:= _
        "password", ReadOnlyRecommended:=False, CreateBackup:=False
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900