PDA

View Full Version : Solved: Save and encrypt sheets



ermis1975
08-01-2008, 01:24 AM
I have a workbook with different worksheets and I want to save each of them as a separate xls file but protected (needs a code to open it).
Thanks!

mdmackillop
08-01-2008, 02:58 PM
Option Explicit
Sub CopySaveProtect()
Dim PW As String
Dim pth As String
Dim sh As Worksheet
pth = ActiveWorkbook.Path
PW = "PW"
For Each sh In Sheets
sh.Copy
With ActiveWorkbook
.SaveAs pth & "\" & sh.Name & ".xls", Password:=PW
.Close
End With
Next
End Sub