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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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!



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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Problem: Worksheets("New Style 2006").Unprotect Password:="naPrint" Karoo News[_2_] Excel Programming 1 January 30th 06 02:40 PM
Modify Recorded SQL Query to "Insert, Delete, Update" MSweetG222 Excel Programming 2 October 25th 05 01:49 AM
Modify "pick from list" to read named range N E Body Excel Programming 3 January 29th 05 09:21 PM
Modify ? Tom Ogilvy "count visible filter records" Todd F. Excel Programming 1 June 11th 04 09:03 PM


All times are GMT +1. The time now is 03:01 AM.

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

About Us

"It's about Microsoft Excel"