View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Backup Copy of Source File

Bob,

Sub BackUpWithIncrementedName()
Dim i As Integer
Dim myFN As String
i = 0

FindAName:
i = i + 1
myFN = ThisWorkbook.Path & "\Archive\" & _
Replace(ThisWorkbook.Name, ".xls", Format(i, "-00") & ".xls")
If Dir(myFN) = "" Then
GoTo DoTheSave
Else
GoTo FindAName
End If

DoTheSave:

ThisWorkbook.SaveCopyAs myFN
MsgBox "I just saved a copy as " & myFN

End Sub

HTH,
Bernie
MS Excel MVP


"Bob Zimski" wrote in message
...
I would like to make a make a backup copy and dump it into one directory
deeper called 'Archive' before manipulating the file in the current
directory. If the filename already exists in the Archive directory, then I
would want to add a '-01' or '-02' etc.. to the next revision level. I know
about the FileCopy command, but have no idea how to determine if the file
already exists inthe archive directory and therefore add the next available
revision number.

Thanks