title: Using VBA macro to open, lock cells, then protect workbooks, but can still edit LOCKED, PROTECTED cells
body: <p>I need to update many old 2003 .xls files to lock and protect a block of cells to keep people from opening the cells and copying out the header information. This is a one-time process, unfortunately, I can't just block off\restrict access to the files.</p>
  
  <p>Using Excel 2010 in compatibility mode I have cobbled together a macro that opens the files, locks the cells, protects the worksheets, then saves and closes the file and moves on to the next file. However, when I manually re-open the files I am still able to copy from the locked cells. Worksheet is showing as protected, when I unlock the cells they show as locked AND they show select locked cells is checked. Any ideas?</p>
  
  <pre><code>Sub Lockdown()
  
  Dim wBk As Workbook
  Dim sFileSpec As String
  Dim sPathSpec As String
  Dim sFoundFile As String
  
  sPathSpec = "C:\Archive\PF\"
  sFileSpec = "*.xls"
  
  sFoundFile = Dir(sPathSpec &amp; sFileSpec)
  Do While sFoundFile &lt;&gt; ""
      Set wBk = Workbooks.Open(sPathSpec &amp; sFoundFile)
      With wBk
          Application.DisplayAlerts = False
           For Each ws In Worksheets
              ws.Unprotect 'Some worksheets have protection without password
              ws.Unprotect Password:="A1234" 'some worksheets have password protection
              ws.Range("A1:I10").Locked = True
              ws.Protect contents:=True
              Next
          Application.DisplayAlerts = True
      End With
      Set wBk = Nothing
      Workbooks(sFoundFile).Close True
      sFoundFile = Dir
  Loop
  
  End Sub
  </code></pre>
  
  <p>Thanks for any help!</p>