Manage Learn to apply best practices and optimize your operations.

Secure Microsoft Excel spreadsheets with LotusScript

Want to protect your Microsoft Excel spreadsheets from tampering? This LotusScript code from SearchDomino.com member Prasad Knair programmatically lets you secure a Microsoft Excel file with a password and prohibit what columns can be edited.

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:

 

Dig Deeper on LotusScript

SearchWindowsServer

Search400

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury

SearchDataCenter

SearchContentManagement

Close