 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Herbert dela Cruz Guest
|
Posted: Mon Sep 11, 2006 4:51 pm Post subject: Saving Password Protected Word Files |
|
|
Hi everyone!
This is somewhat related to my earlier posts, but this time, instead of
opening password protected docs, my problem is with saving them. My code
is below:
=== begin code ===
ShowMessage (PassedWord);
if docSaved Then Exit;
OleContainer.SaveAsDocument(FileName);
OleContainer.Close;
WordApp.Documents.Open (FileName, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam);
WordApp.ActiveDocument.Password := Passedword;
WordApp.ActiveDocument.Save;
WordApp.ActiveDocument.Close(EmptyParam, EmptyParam, EmptyParam);
If Not (isQuitting) Then OleContainer.DoVerb(ovPrimary);
docSaved := True;
=== end code ===
The PassedWord variable is the password to be used to protect the
document. And I derived the code from this VBA:
== begin VBA code ===
With ActiveDocument
.ReadOnlyRecommended = False
.EmbedTrueTypeFonts = False
.SaveFormsData = False
.SaveSubsetFonts = False
.Password = "test"
.WritePassword = ""
.OptimizeForWord97 = False
End With
Application.DefaultSaveFormat = ""
ActiveDocument.Save
=== end VBA code ===
Thanks for the help. :D
Cheers! |
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Tue Sep 12, 2006 1:06 am Post subject: Re: Saving Password Protected Word Files |
|
|
Hi,
you need call the Protect method before Save instead change the Password
property:
document.Protect(Password := yourPassword);
document.SaveAs(yourFileName);
document.Close;
--
With best regards, Mike Shkolnik
E-mail: mshkolnik (AT) scalabium (DOT) com
WEB: http://www.scalabium.com
"Herbert dela Cruz" <renegade_havoc (AT) yahoo (DOT) com> wrote in message
news:MPG.1f6fce8142f60038989684 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi everyone!
This is somewhat related to my earlier posts, but this time, instead of
opening password protected docs, my problem is with saving them. My code
is below:
=== begin code ===
ShowMessage (PassedWord);
if docSaved Then Exit;
OleContainer.SaveAsDocument(FileName);
OleContainer.Close;
WordApp.Documents.Open (FileName, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam);
WordApp.ActiveDocument.Password := Passedword;
WordApp.ActiveDocument.Save;
WordApp.ActiveDocument.Close(EmptyParam, EmptyParam, EmptyParam);
If Not (isQuitting) Then OleContainer.DoVerb(ovPrimary);
docSaved := True;
=== end code ===
The PassedWord variable is the password to be used to protect the
document. And I derived the code from this VBA:
== begin VBA code ===
With ActiveDocument
.ReadOnlyRecommended = False
.EmbedTrueTypeFonts = False
.SaveFormsData = False
.SaveSubsetFonts = False
.Password = "test"
.WritePassword = ""
.OptimizeForWord97 = False
End With
Application.DefaultSaveFormat = ""
ActiveDocument.Save
=== end VBA code ===
Thanks for the help. :D
Cheers! |
|
|
| Back to top |
|
 |
Oliver Townshend Guest
|
Posted: Tue Sep 12, 2006 2:17 am Post subject: Re: Saving Password Protected Word Files |
|
|
| Quote: | you need call the Protect method before Save instead change the Password
property:
document.Protect(Password := yourPassword);
document.SaveAs(yourFileName);
document.Close;
|
Protecting a document with a password isn't the same as saving it with a
password. Protect allows you to open the document but not alter it, whereas
password protection at open/save stops you opening it altogether.
Oliver Townshend |
|
| Back to top |
|
 |
Herbert dela Cruz Guest
|
Posted: Tue Sep 12, 2006 7:10 pm Post subject: Re: Saving Password Protected Word Files |
|
|
Hi!
| Quote: | Protecting a document with a password isn't the same as saving it with a
password. Protect allows you to open the document but not alter it, whereas
password protection at open/save stops you opening it altogether.
|
Which was what I thought I was doing with the
WordApp.ActiveDocument.Password line. However, the document doesn't save
the password. Is there something else missing, perhaps?
Thanks for the help. :D
Cheers! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|