Board index » delphi » How do I make a Word.Document or Excel.Worksheet READONLY

How do I make a Word.Document or Excel.Worksheet READONLY

Hi,
    I am using Word and Excel for reporting, so hence I wish to make the
documents created READONLY, or something like that to stop users changing
their contents.

I think I am not too far off as far as Excel goes, I am just a bit confused
with some of the params:-
Procedure TestExcel;
var
  WS: _WorkSheet;
  WSheet: Sheets;
  DrawingObjects, Contents, Scenarios : OleVariant;
begin
  WSheet := Excel.Worksheets;
  WS := WSheet.Get_Item(1) as _WorkSheet;
  WS.Name := 'Belmay Ltd';
  WS.cells.Item[3, 2] := 'HELLO THIRD ROW, SECOND COLUMN';
  WS.Protect (' ', DrawingObjects, Contents, Scenarios,
EmptyParam,EmptyParam);  ///?????????
end;

I am not sure at all about Word - do I have to save it first as I'd rather
not have to - all I want to do is make it so the users can't change it !

--
Many Thanks -
Please CC Responses To :-

Antho...@Belmay.Co.UK

 

Re:How do I make a Word.Document or Excel.Worksheet READONLY


<<Anthony D:
I wish to make the documents created READONLY

Quote

var
  OleTrue: OleVariant;
..
  OleTrue := True;
  WS.Protect(EmptyParam, OleTrue, OleTrue,
             OleTrue, EmptyParam, lcid);

<<Anthony:
I am not sure at all about Word

Quote

  Doc.Protect(wdAllowOnlyFormFields);

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads