
MsgBox "This file has not been initially saved. MsgBox "New file version saved (version " & x & ")" If FileExist(FolderPath & SaveName & VersionExt & x & SaveExt) = False ThenĪctiveWorkbook.SaveAs FolderPath & SaveName & VersionExt & x & SaveExt If FileExist(FolderPath & SaveName & SaveExt) = False ThenĪctiveWorkbook.SaveAs FolderPath & SaveName & SaveExt If InStr(1, myFileName, VersionExt) > 1 Then SaveExt = "." & Right(myPath, Len(myPath) - InStrRev(myPath, ".")) MyFileName = Mid(myPath, InStrRev(myPath, "\") + 1, InStrRev(myPath, ".") - InStrRev(myPath, "\") - 1)įolderPath = Left(myPath, InStrRev(myPath, "\")) 'PURPOSE: Save file, if already exists add a new version indicator to filename You can just paste the below code below either the Excel, PowerPoint, or Word subroutines. MAKE SURE that you include this function along with any of the application macro code versions shown below. The below function code is what I was able to glean from Ron's article. Be sure to check out his full article, Test if Folder, File or Sheet Exists or File is Open as it is a great read. I found a great article on Ron de Bruin's website detailing various ways to check if something exists with VBA code. This is very important in order to determine the proper version number to use. In order for the main VBA code to work, you will need to use a small function that determines if a specific file (via file path) exists on your computer. Luckily there aren't too many differences between the three macros sets. I decided to write VBA code for Excel as well as Miscrosoft Word and PowerPoint in case you would like to use the same process with your documents and presentations. Below I will list a few of the major capabilities our VBA code will need to possess.ĭetermine if a previous version already existsĭetermine where the file is saved (or if it is saved at all)Ĭreate a new version with an incremental version extension (for example adding "_v2" to the end of the file name) Let's first think through what we will need to code. Let's walk through how I personally would tackle this problem and see if we can come up with an efficient solution. This was a great question and really caught my attention.

However I received a question from a reader who goes by the name Kauket, asking if it was possible to automate saving a new version for a file.

I am grateful that I have access to Microsoft SharePoint at my company and am able to easily save a new version without even thinking. Keeping track of different versions of a file has always been a pain for me.
