Click here to Skip to main content
13,044,398 members (119,885 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 18-Feb-13 1:33am
ryanb31 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 R. 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100