De: Jan Karel Pieterse Objet: Re: Protecting worksheets by using Excel 97 VBA Date : lundi 20 septembre 1999 07:57 Hi William, Try this: Option Explicit Sub ProtectThemAll() dim sFileList() As String dim sDirect As String dim sFileSpec As String dim icounter As Integer dim iFilecount As Integer dim sSheet As Worksheet sDirect = "c:\data\" 'Change accordingly sFileSpec = "t*.xls" 'Change accordingly application.screenupdating = false icounter = 1 redim sFileList(1) As String sFileList(1) = Dir(sDirect & sFileSpec) if sFileList(1) = "" then msgbox ("Found no Files like " & sDirect & sFileSpec) Exit Sub end if do icounter = icounter + 1 redim preserve sFileList(icounter + 1) As String sFileList(icounter) = Dir() loop Until sFileList(icounter) = "" iFilecount = icounter-1 for icounter = 1 to iFilecount workbooks.Open filename:=sDirect & sFileList(icounter) for each sSheet In activeworkbook.worksheets 'Assuming there are only those 13 to be protected! sSheet.Protect password:="yourpassword", DrawingObjects:=true, contents:=true, Scenarios:=true next sSheet activeworkbook.Close savechanges:=true next icounter end Sub -- Kind regards, Jan Karel Pieterse jkpieterse@zzzcompuservezzz.com (remove all z's) William SMITH wrote in article <37e5b8ea@ruby.hknet.com>... > Mr.tom Ogilvy, > > May I ask you a question regarding protecting worksheets in Excel 97. I got > 50 workbooks. each contains 13 worksheets. I would like to protect each > worksheets with a same passwords. How could I write a Excel VBA to execute > this task. > > Thank you very much for your reply. > > > Will Smith > > >