Board index » delphi » OLEAutomation and MSWord97 Password

OLEAutomation and MSWord97 Password

Hi All,

I Would like to find more information on opening a document protected
with a password.
Could someone just tell me how can I pass the parameters

Thanks a lot

Patrick Vandervoort
Belgium

 

Re:OLEAutomation and MSWord97 Password


<<P. Vandervoort:
 I Would like to find more information on opening a document
protected with a password.
Could someone just tell me how can I pass the parameters

Quote

It depends whether you're using early binding or variants.
With a variant MSWord:
  MSWord.Documents.Open(FileName := 'C:\My Documents\Password.doc',
                        PasswordDocument := 'midget');

With early binding you have to put something in for all
the optional parameters, like this:
var
  FileName, Password: OleVariant;
begin
  FileName := 'C:\My Documents\Password.doc';
  Password := 'midget';
  MSWord.Documents.Open(FileName, EmptyParam, EmptyParam,
                        EmptyParam, Password, EmptyParam,
                        EmptyParam, EmptyParam,
                        EmptyParam, EmptyParam);

Deborah Pate

Re:OLEAutomation and MSWord97 Password


Thanks for your help.

Patrick

Quote
Deborah Pate wrote:
> <<P. Vandervoort:
>  I Would like to find more information on opening a document
> protected with a password.
> Could someone just tell me how can I pass the parameters

> It depends whether you're using early binding or variants.
> With a variant MSWord:
>   MSWord.Documents.Open(FileName := 'C:\My Documents\Password.doc',
>                         PasswordDocument := 'midget');

> With early binding you have to put something in for all
> the optional parameters, like this:
> var
>   FileName, Password: OleVariant;
> begin
>   FileName := 'C:\My Documents\Password.doc';
>   Password := 'midget';
>   MSWord.Documents.Open(FileName, EmptyParam, EmptyParam,
>                         EmptyParam, Password, EmptyParam,
>                         EmptyParam, EmptyParam,
>                         EmptyParam, EmptyParam);

> Deborah Pate

Other Threads