Re: Protect an excel spreasheet by script in LotusNotes

Giganews Newsgroups
Subject: Re: Protect an excel spreasheet by script in LotusNotes
Posted by:  Harlan Grove (hrlng…@gmail.com)
Date: Thu, 24 Jul 2008

Georges <georges.rob.…@gmail.com> wrote...
>In a LotusNotes dB I Create a spreadsheet from a view with the use
>of =A0'CreateObject("Excel.Application")'
=2E..

CreateObject is a function call and should return an Excel application
object referring to a running instance of Excel when successful.
Presumably you're assigning its result to a variable of type Object.
If so, and if there were only one workbook open in that Excel
instance, you could protect each worksheet and the workbook using code
similar to the following.

'NOTE: LotusScript code, **NOT** VBA code
Sub foo
    Dim xl As Variant, wb As Variant

    'possibly other code here

    Set xl =3D createobject("Excel.Application")
    Set wb =3D xl.workbooks.add

    'possibly other code here

    'note: Lotus was BRAINDEAD when they designed LotusScript
    'Forall loop variables must be UNDECLARED when used,
    'thus ws wasn't declared above
    Forall ws In wb.Worksheets
        'different passwords for different worksheets
        'left as an exercise
        ws.Protect "your worksheet password here"
    End Forall

    'possibly other code here

    wb.Protect "your workbook password here", True, True

    wb.SaveAs "your filename here", , _
      "your file open password here", _
      "your file modify password here", True

    wb.close False

    'possibly other code here

    xl.Quit

    'possibly other code here

End Sub

Replies

In response to

Protect an excel spreasheet by script in LotusNotes posted by Georges on Wed, 23 Jul 2008