
Untitled
By: a guest on
Jun 13th, 2012 | syntax:
None | size: 0.69 KB | hits: 23 | expires: Never
How can I see if a Word-file is password-protected?
// Open the document...
this.document = wordApplication.Documents.Open(
ref inputFile, ref confirmConversions, ref readOnly, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref visible,
ref missing, ref missing, ref missing, ref missing);
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