Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Protecting Word Document - Batch process

Status
Not open for further replies.

shaleen7

MIS
Jun 23, 2002
188
US
I need to protect 75 word documents. I don't want to open each document one at a time. Is there a way to protect all the word documents at once.

Thanks
 
In what way do you want to protect them?
Please provide the manual steps you would take to protect ONE.
:)

(There's Tools-Protect document, and then password-protecting for opening or modifying...)

Anne Troy
Supercharge your Office Applications:
 
Code:
Sub ProtectDocuments() 
     
    On Error Goto ErrHandler 
     
    Dim dlgSelect As FileDialog 
     
    Set dlgSelect = Application.FileDialog(msoFileDialogFolderPicker) 
    dlgSelect.Show 
     
    With Application.FileSearch 
        .FileType = msoFileTypeWordDocuments 
        .LookIn = dlgSelect 
        .Execute 
        For I = 1 To .FoundFiles.Count 
            Set myDoc = Documents 
            myDoc.Open FileName:=dlgSelect & "\" & myDoc 
            myDoc.Password = strPassword 
            myDoc.Close 
             
        Next I 
    End With 
     
    Exit Sub 
     
ErrHandler: 
    MsgBox Err.Description 
    Exit Sub 
     
End Sub

Know what to do with it?

Anne Troy
Supercharge your Office Applications:
 
The short answer, and I a sorry to say, is no. You can not protect the 75 files without opening them.

Protect is an iternal process within Word. therefore it most have an instance running to execute the protection.

As for comments regarding Ane's code:

1 I have to point out that what it does (and notice that it DOES, in fact open the files) it a file protection via a password, on the file itself.

2. the password "strPassword" is neither declared, nor defined. The password that would be set for each file would be NULL, not "" - or blank. This is significant difference. In other words, the variable strPasword is not even defined as a String, so it would default to a type Variant, which, as it is used, would put the value as "Null". This is not a good idea.

3. If you have formfields that need protection so they can function, this code will not do that.

Please post if what you need is a file protection (ie. a password required to open the file; or protection inorder to make forms within the document function.



Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top