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:

 

This was first published in February 2007

Dig deeper on LotusScript

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close