HasPassword property

A

Agos

Hi all,
I've a recursive function that open .doc files on HDD, but
some of them can be password-protected...
I tried with the
Documents.Open(FileName).HasPassword
property, but Word still ask me password and
after that he continues with the code.
How can I ignore password-protected files from opening?

Agos
 
G

Gandalf

Hi Agos

I've found that this approach works

Dim dobj As Document
On Error Resume Next
set dobj=Documents.Open("C:\Temp\Passwordeddoc.doc", , , , " ", " ", , "
", " ", , , True)
err.clear
If dobj Is Nothing Then
MsgBox "Error Password Protected and wrong password supplied"
Else
MsgBox "No error File should be open"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top