by Don (3 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 12th August 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Check If an MS Excel or Acccess File is password protected
API Declarations
Use:
1)start new project
2)add a command button and a text box
3)in command button code enter
msgbox(Password_Check(Text1))
4)run program, type in file location in textbox and hit command button. It'll com eup with a msgbox with a true or false if the file is password protected.
Note: this will only work on xls or mdb files.
Dim db As DAO.Database
If Right(Path, 3) = "mdb" Then
On Error GoTo errorline
Set db = OpenDatabase(Path)
Password_Check = "False"
Exit Function
ElseIf Right(Path, 3) = "xls" Then
On Error GoTo errorline
Set db = OpenDatabase(Path, True, False, "Excel 5.0")
Password_Check = "False"
Exit Function
Else
Password_Check = "0"
Exit Function
End If
errorline:
Password_Check = "True"
Exit Fu