View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default unlock workbooksin hundred of excel files

sorry - that was file level protection. For workbook protection as you
describe

Dim bk as Workbook, sPath as String
Dim sStr as String
sPath = "C:\MyFolder\"
sStr = Dir(sPath & "*.xls")
do while sStr < ""
set bk = workbooks.Open( filename:=sStr)
bk.Unprotect Password="ABC"
bk.close Savechanges:=True
sStr = Dir()
Loop

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Dim bk as Workbook, sPath as String
Dim sStr as String
sPath = "C:\MyFolder\"
sStr = Dir(sPath & "*.xls")
do while sStr < ""
set bk = workbooks.Open( filename:=sStr, _
password:="ABCD")
Application.DisplayAlerts = True
bk.SaveAs bk.FullName
Application.DisplayAlerts = False
bk.close Savechanges:=False
sStr = Dir()
Loop

--
Regards,
Tom Ogilvy

"guilhaume " wrote in message
...
Thx a lot, but I think I didn't explain very well what I wanted to do
:)
It is to say:
have a script that takes out the workbook's protection without having
to open the excel file with Office and do 'Utils', 'Protection',
'Unprotect the workbook' (problably the menu names are wrong, as I am
french I tested a translation... ;))

in fact I wanted a script like that:

for all the files f in the directory d do
f.unprotectWorkbook()
end

reguards


---
Message posted from http://www.ExcelForum.com/