Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password protected Excel File IT Service Agent Excel Discussion (Misc queries) 1 May 20th 08 07:34 PM
Forgot excel file password Suresh Lohar Excel Discussion (Misc queries) 2 March 26th 06 11:47 PM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM
bypass password when update linking of password protected file Yan Excel Discussion (Misc queries) 1 February 7th 05 11:29 PM
password protected a check box Glendon MacBurnie Excel Worksheet Functions 0 January 27th 05 07:52 PM


All times are GMT +1. The time now is 10:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"