Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check excel file for password

Status
Not open for further replies.

jenmcclary

Programmer
Sep 16, 2002
12
0
0
US

I have a directory with numerous excel files some of these files are password protected. I will be moving all of these files into 2 different directories. One directory will hold the password protected files, the other directory will hold the files with no protection.

Dim FileName As String
Dim mainWB As Workbook

Set mainWB = ActiveWorkbook
FileName = "C:\AA\Bill\HasPassword\The Rockefeller Foundation.xls"
Workbooks.Open FileName:=FileName
If ActiveWorkbook.HasPassword = True Then
MsgBox "Has Password"
Else
MsgBox "No Password"
End If
ActiveWindow.Close

This doesn't work because the excel workbook hangs waiting for you to enter a password. I don't want to enter a password I just want to see if the file has password protection and then move it. I have the moving part under control I just need help with checking for password protection.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top