Results 1 to 10 of 10

Creating a backup protected with pw

Threaded View

  1. #1
    Registered User
    Join Date
    12-16-2014
    Location
    Czech
    MS-Off Ver
    2010
    Posts
    18

    Creating a backup protected with pw

    Hello,

    I want to create a backup excel workbook encrypted with password whenever I hit a button save.

    So far I have this but still canīt figure out how to protect all new .xlsm files with password so noone canīt do a change in backup files without knowing a password. Saving and creating backup files in different folder works.

    Thanks.

    Private Sub Workbook_AfterSave(ByVal Success As Boolean)
       
       
        Dim DestinationFolder   As String
        Dim WbName              As String
        Dim WbExtension         As String
        Dim WbNewPath           As String
        Dim sHostName           As String
       
        sHostName = Environ$("computername")
        
        DestinationFolder = "C:\Users\An\Dropbox\Orders - backup"
       
        If DestinationFolder = "" Or Dir(DestinationFolder, vbDirectory) = vbNullString Then
            MsgBox "The destination folder's path is incorect!", vbCritical, "Wrong folder's path"
            Exit Sub
        End If
           
        WbName = Left(ThisWorkbook.Name, (InStrRev(ThisWorkbook.Name, ".", -1, vbTextCompare) - 1))
       
        WbExtension = Right$(ThisWorkbook.Name, Len(ThisWorkbook.Name) - InStrRev(ThisWorkbook.Name, "."))
    
        WbNewPath = DestinationFolder & "\" & WbName & sHostName & "(" & Format(Now(), "dd.mm.yyyy - hh.mm") & ")." & WbExtension
       
        ThisWorkbook.SaveCopyAs WbNewPath
       
    End Sub
    Last edited by pandemic; 02-09-2015 at 09:52 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel is creating .xlsm backup automatically--why?
    By alansidman in forum Excel General
    Replies: 0
    Last Post: 06-02-2011, 10:13 PM
  2. Creating Backup file! (Not Save-as)
    By Rick_Stanich in forum Excel General
    Replies: 1
    Last Post: 11-24-2009, 06:34 PM
  3. Creating Backup
    By Brian L Matlack in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2008, 01:50 PM
  4. Creating a backup of Excel Workbooks
    By BigBas in forum Excel General
    Replies: 1
    Last Post: 10-10-2007, 11:43 AM
  5. Creating a Backup copy of workbook
    By justaguyfromky in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-03-2006, 07:10 PM

Tags for this Thread

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