Results 1 to 10 of 27

Thread: Save Workbook File With The Next Incrementing Version Number Index

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    Not sure about this. BACKUP your original file before trying this solution.

    Put this code in the workbook module.

    Code:
    Option Explicit
    
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
        
        Dim NewName     As String
        Dim iNum        As Long
        Dim OldName     As String
        Dim FileF       As Long
        Dim FileNm      As String
        
        Const FName     As String = "Ivan Ivanov"
        
        With ThisWorkbook
            OldName = .FullName
            FileF = .FileFormat
            FileNm = Left$(.Name, InStrRev(.Name, ".") - 1)
            iNum = Mid(FileNm, Len(FName) + 1)
            NewName = .Path & Application.PathSeparator & FName & iNum + 1 & ".xlsm"
            Application.DisplayAlerts = False
            Application.EnableEvents = False
            .ChangeFileAccess xlReadOnly
            FileCopy OldName, NewName
        End With
        Application.DisplayAlerts = True
        Application.EnableEvents = True
        Kill OldName 'comment this line if you want to keep the old file
        ThisWorkbook.Close 0
    End Sub
    Last edited by Admin; 07-12-2013 at 11:27 PM.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

Similar Threads

  1. Replies: 4
    Last Post: 06-20-2013, 04:25 PM
  2. Replies: 7
    Last Post: 04-21-2013, 07:50 PM
  3. How To Save Macro To Personal Workbook
    By NITIN SHETTY in forum Excel Help
    Replies: 1
    Last Post: 04-07-2013, 01:07 PM
  4. Copy Sheets To New Workbook And Save
    By Prabhu in forum Excel Help
    Replies: 5
    Last Post: 09-06-2011, 09:35 PM
  5. Replies: 1
    Last Post: 06-02-2011, 10:38 AM

Posting Permissions

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