Click here to Skip to main content
11,573,618 members (63,787 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 18-Feb-13 1:33am
Comments
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
good
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[^]
  Permalink  

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

  Print Answers RSS


Advertise | Privacy | Mobile
Web04 | 2.8.150624.2 | 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