Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Problem: Worksheets("New Style 2006").Unprotect Password:="naPrint" | Excel Programming | |||
Modify Recorded SQL Query to "Insert, Delete, Update" | Excel Programming | |||
Modify "pick from list" to read named range | Excel Programming | |||
Modify ? Tom Ogilvy "count visible filter records" | Excel Programming |