Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is there code to test an unopened file to see if it has a password. I just
want it to return True or False or something like that, that the file is password protected or not. And definitely I do not want to have to open the file I am testing first. Thank you, Steven |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I haven't tried it on an unopened workbook, you could possibly substitute the
workbook name for ActiveWorkbook and try it. Workbooks("FileName.xls") format. If ActiveWorkbook = True Then MsgBox "File had Password" Else MsgBox "Not Password Protected" End If "Steven" wrote: Is there code to test an unopened file to see if it has a password. I just want it to return True or False or something like that, that the file is password protected or not. And definitely I do not want to have to open the file I am testing first. Thank you, Steven |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think that will work. Thank you. The issue is since in code you can put
Workbooks.Open FileName:="aaaa.xls", Password:="whatever" and it will open if the file does not have a password, which is unusual to me, then just test the opened file from the original file to make sure it was password protected, then that means the password had to match. If it opens and "No Password" then just close the file without saving. Thank you again, Steven "JLGWhiz" wrote: I haven't tried it on an unopened workbook, you could possibly substitute the workbook name for ActiveWorkbook and try it. Workbooks("FileName.xls") format. If ActiveWorkbook = True Then MsgBox "File had Password" Else MsgBox "Not Password Protected" End If "Steven" wrote: Is there code to test an unopened file to see if it has a password. I just want it to return True or False or something like that, that the file is password protected or not. And definitely I do not want to have to open the file I am testing first. Thank you, Steven |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I just tried it and as I suspected, it gives a Subscript Out of Range
message. So I would imagine that it would be simpler to just write the code as you said to do a logical test when opening the file and handle it with code. "Steven" wrote: I think that will work. Thank you. The issue is since in code you can put Workbooks.Open FileName:="aaaa.xls", Password:="whatever" and it will open if the file does not have a password, which is unusual to me, then just test the opened file from the original file to make sure it was password protected, then that means the password had to match. If it opens and "No Password" then just close the file without saving. Thank you again, Steven "JLGWhiz" wrote: I haven't tried it on an unopened workbook, you could possibly substitute the workbook name for ActiveWorkbook and try it. Workbooks("FileName.xls") format. If ActiveWorkbook = True Then MsgBox "File had Password" Else MsgBox "Not Password Protected" End If "Steven" wrote: Is there code to test an unopened file to see if it has a password. I just want it to return True or False or something like that, that the file is password protected or not. And definitely I do not want to have to open the file I am testing first. Thank you, Steven |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Test if a file is password protected | Excel Programming | |||
PASSWORD REMOVAL I have the password to open the file and the password to modify the file now how to remove them | Excel Programming | |||
Open Test file with VBA with a changing file number | Excel Programming | |||
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) |