+ Reply to Thread
Results 1 to 2 of 2

macro to password protect exel file

  1. #1
    anelh6
    Guest

    macro to password protect exel file

    Hi,
    I need to password protect hundreds of exel files with the same password,
    but my boss wants them done one by one (as opposed to a zip file). The files
    are in different directories and have different names. Can I create a macro
    that will do the following once I have the file open?
    Go to Save As
    Go to Tools
    Select General Options
    Enter password to protect (i.e. 1234)
    click OK
    Retype password
    Click OK
    Save

    I have been doing this for the past hour one file at a time and my fingers
    are really tired now. Any help is GREATLY appreciated.

  2. #2
    Tom Ogilvy
    Guest

    Re: macro to password protect exel file

    Look at help on the Workbook.SaveAs command. Password is one of the
    arguments.

    Sub PasswordFiles()
    Dim sFname as String, sPath as String
    sPath = "C:\My Folder\"

    sFname = Dir(sPath & "*.xls")
    do While sFname <> ""
    Workbooks.Open sPath & sFname

    Application.DisplayAlerts = False
    ActiveWorkbook.Saves FileName:=ActiveWorkbook.fullname, _
    FileFormat:=xlWorkbookNormal, Password:="1234"
    Application.DisplayAlerts = True
    ActiveWorkbook.Close SaveChanges:=False
    sFname = Dir()
    Loop
    End Sub

    --
    Regards,
    Tom Ogilvy


    "anelh6" <anelh6@discussions.microsoft.com> wrote in message
    news:E5AD8A9E-E29E-492A-9A21-A1191BE8770B@microsoft.com...
    > Hi,
    > I need to password protect hundreds of exel files with the same password,
    > but my boss wants them done one by one (as opposed to a zip file). The

    files
    > are in different directories and have different names. Can I create a

    macro
    > that will do the following once I have the file open?
    > Go to Save As
    > Go to Tools
    > Select General Options
    > Enter password to protect (i.e. 1234)
    > click OK
    > Retype password
    > Click OK
    > Save
    >
    > I have been doing this for the past hour one file at a time and my fingers
    > are really tired now. Any help is GREATLY appreciated.




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1