Private
Function
Versionize(File
As
String
)
As
String
Dim
strFilename
As
String
strFilename = Dir$(File)
If
strFilename =
""
Then
Versionize = File
Exit
Function
End
If
Dim
strPath
As
String
Dim
strId
As
String
Dim
strExtension
As
String
strPath = Left$(File, Len(File) - Len(strFilename))
strExtension = Right$(strFilename, Len(strFilename) - InStrRev(strFilename,
"."
))
If
Len(strExtension) > 0
Then
strFilename = Left$(strFilename, Len(strFilename) - Len(strExtension) - 1)
End
If
While
IsNumeric(Right$(strFilename, 1))
strId = Right$(strFilename, 1) & strId
strFilename = Left$(strFilename, Len(strFilename) - 1)
Wend
strId = Val(strId) + 1
strFilename = strFilename & strId &
"."
& strExtension
Versionize = Versionize(strPath & strFilename)
End
Function