Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to check for password in an excel file.
Hi,
I would like to know how I can check whether an excel file is password protected or not. Thanks, Aatash |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to check for password in an excel file.
Hi Aatash,
Aatash wrote: I would like to know how I can check whether an excel file is password protected or not. I'm not sure if you can determine that without attempting to open the file. If you specify a password when opening a workbook, that password will be ignored if the workbook is not password-protected. If the workbook is password-protected and the password you supply is incorrect, you'll get a 1004 runtime error, which you can trap: Sub test() On Error GoTo ErrHandler Workbooks.Open Filename:="c:\book1.xls", Password:="$$$$" ExitRoutine: Exit Sub ErrHandler: If Err.Number = 1004 And InStr(1, Err.Description, _ "Password", vbTextCompare) Then MsgBox "Password-protected workbook. Unable to open.", _ vbExclamation, "Error" Else MsgBox CStr(Err.Number) & ": " & Err.Description End If Resume ExitRoutine End Sub -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Password protected Excel File | Excel Discussion (Misc queries) | |||
Forgot excel file password | Excel Discussion (Misc queries) | |||
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. | Excel Worksheet Functions | |||
bypass password when update linking of password protected file | Excel Discussion (Misc queries) | |||
password protected a check box | Excel Worksheet Functions |