![]() |
Testing for "Password to modify"
I have a program that I've written in VBA (from Word) that opens and
modifies all of the Excel documents in a directory. The program hangs when it reaches documents that have "Password to modify" set. These documents don't have a "Password to open" set, so the check "HasPassword" check returns false. I can't find any other check like this (for the "Password to modify"), and am looking for help. I don't want to get around the password, just to leave my routine and move onto the next document. To restate, if I come across a document that has a "Password to modify" set, I want to close it and move onto the next document. Thanks in advance. Robert Brown |
Testing for "Password to modify"
Hey there
You could incorporate this snippet of code that was a reply by Thom Ogilvy to a question similar to your own. S This is tested and works in Excel: Sub AAATEst() Dim wkbk As Workbook On Error Resume Next Set wkbk = Workbooks.Open("C:\Data6\AAABook.xls", _ Password:="", WriteResPassword:="") On Error GoTo 0 If wkbk Is Nothing Then MsgBox "Has Password" End If End Sub It will open a workbook that is not password protected. don't know if it will work for .Net. -- Regards, Tom Ogilvy |
Testing for "Password to modify"
Thanks for the reply, that's the solution that I ended up implementing,
but it really would be nice if there was a way to simply test for it, rather than using an error handler to determine that it didn't open. I appreciate the response though! |
Testing for "Password to modify"
To me, such error handling IS a form of information.
There is nothing wrong with that approach. If it is you creating these protected file, you could add a Custom Property ("HasPW") to the WB, which you can check beforehand with the MS DSOFile.dll. But it hardly seems worth it. NickHK wrote in message ups.com... Thanks for the reply, that's the solution that I ended up implementing, but it really would be nice if there was a way to simply test for it, rather than using an error handler to determine that it didn't open. I appreciate the response though! |
All times are GMT +1. The time now is 01:56 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com