Click here to Skip to main content
11,802,442 members (70,883 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#

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 at 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 at 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 at 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
0 KrunalRohit 366
1 OriginalGriff 365
2 F-ES Sitecore 295
3 Afzaal Ahmad Zeeshan 230
4 CPallini 230
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,645
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2015
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