Want to protect Microsoft Excel spreadsheets from tampering? This LotusScript code only allows users to edit columns
that you specify as permitted. Other columns can be locked programmatically, and the Microsoft Excel file will be protected with a password. The only way for the secured columns to be edited is for the user to know the password and edit them after entering it.
'Setting the Excel object. Set ExcelApp = CreateObject("Excel.Application") Set ExcelWorkbook = ExcelApp.Workbooks.Open("C:TempTest.xls") Set ExcelWorksheet = ExcelWorkbook.Application.Workbooks(1).Worksheets(1) ' You can enter the values and once the entry is over lock the columns. With ExcelWorksheet ' .Range("A1:B1").Select .Range("A1").Value ="Prasad" .Range("B1").Value ="Lekshmi" .Range("A1:B1").Locked=True .Range("A2:A10").Locked=False End With ExcelWorksheet.Protect Password="1234" ' You just need one line to protect excel sheet from tampering. ExcelWorkbook.Save ExcelApp.quit Set ExcelApp=Nothing
Do you have comments on this tip? Let us know.
Related information from SearchDomino.com:
- Featured Topic: LotusScript and Excel
- Learning Guide: LotusScript
- FAQ: LotusScript advice
- Reference Center: LotusScript tips and resources
This tip was submitted to the SearchDomino.com tip library by member Prasadknair . Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.