Board index » delphi » Protect a section in a word document using delphi servers

Protect a section in a word document using delphi servers

Hi,

I'm using Delphi 5 to do a program to auto create word documents and save
some informations like date, from, to and subject in a interbase database.
When Ms Word appears the information is already saved in the database and
placed in the word document. Then the user should write the text to complete
the document.
My question is: How can i protect a section in a word document, using the
delphi word servers, to avoid users to edit  the information that is already
in the document when word apears?

Thanks.

 

Re:Protect a section in a word document using delphi servers


<<Eduardo Brinca:
How can i protect a section in a word document

Quote

Set the section's ProtectedForForms property:
  Doc.Sections.Item(1).ProtectedForForms := True;

--
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

Re:Protect a section in a word document using delphi servers


"Deborah Pate (TeamB)" <d.p...@cableinet.co.not-this-bit.uk> escreveu na
mensagem news:VA.000008a1.0182eff4@cableinet.co.not-this-bit.uk...

Quote
> <<Eduardo Brinca:
> How can i protect a section in a word document

> Set the section's ProtectedForForms property:
>   Doc.Sections.Item(1).ProtectedForForms := True;

> --
> 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

First of all thanks for your help, but i have made a litle program to test
your soluction and i can't put it to work properly.
I have a word document (test.doc) with to sections and a delphi form with 3
objects: one word application server (Wapp1), one word document server (wd1)
and one button.
Here is the code:

procedure TForm1.Button1Click(Sender: TObject);

var
 doc,par : olevariant;

begin
doc:='d:\test.doc'; par:=emptyparam;
wapp1.Connect;
wapp1.documents.open(doc,par,par,par,par,par,par,par,par,par);
wd1.ConnectTo(wapp1.activedocument);
wd1.Sections.Item(1).ProtectedForForms:=true;
wapp1.visible:=true;
end;

I had also tried wd1.Sections.Item(1).Set_ProtectedForForms(true) and
wd1.range. ....

This code has no effect in my word document. What i am doing wrong?

I have 3 more questions:
 1- Where can i use de constant wdDialogToolsProtectSection ? (WdWordDialog
constants - Word97.pas)
 2- How can i specify the section i want to protect?
 3- How can i specify a password to unprotect the section?

Thanks,

    E.Brinca

Other Threads