Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I have a folder which contains files of format(DOC,DOCX,GIF,JPG,JPEG,PDF,PNG,PPT,RTF,TIF,TIFF,TXT,XLS,XLSX).
These files may or may not be password protected.

I need to know whether each of the files are password protected or not?

Thanks in advance
Posted
Comments
ZurdoDev 18-Feb-13 7:54am    
I believe you'll have to use the Office libraries to check if any of the office files are password protected. However, things like jpg, tif, how would they be password protected?
Manfred Rudolf Bihy 18-Feb-13 8:06am    
My thoughts exactly! I'll guess OP will have to a bit more specific about what he thinks "password protected" means in this context.
Most of the extensions don't make any sense: GIF, JPG, JPEG, PNG, RTF, TIF, TIFF, TXT.
Marco Bertschi 18-Feb-13 9:12am    
COM.Interop.#officeproduct# to be exact. OP definately needs to be more specific!

1 solution

VB
Sub MyMacro()

Dim oDoc As Document

On Error Resume Next

Set oDoc = Documents.Open(FileName:="C:\MyFile.doc", PasswordDocument:=password)
Select Case Err.Number
    Case 0
     Debug.Print "File was processed."

    Case 5408
     'Debug.Print "Wrong password!"

    Case Else
     MsgBox Err.Number & ":" & Err.Description
End Select


searched from here[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900