I use the following code to add incremental numbers to saved files to avoid duplication/overwriting. As FileSearch is not supported in 2007, what is the most efficient way to do this?
[VBA]
'Check if the attachment name exists, if so, add an increment
Function DocSave(StrFolderPath As String, DocName As String, Ext As String) As String
Dim Ext As String, SaveName As String
Dim fs As FileSearch
Set fs = Application.FileSearch
With fs
.NewSearch
.LookIn = StrFolderPath
.SearchSubFolders = False
.Filename = DocName
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
DocSave = DocName & "-" & .FoundFiles.Count & Ext
Increment = True 'to show "Saved As" message
Else
DocSave = DocName & Ext
End If
End With
Set fs = Nothing
End Function
[/VBA]