Consulting

Results 1 to 2 of 2

Thread: Solved: Save and encrypt sheets

  1. #1

    Solved: Save and encrypt sheets

    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!

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]
    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

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •