-
Try this procedure out. It'll rename the file based on how many files are already in the specified folder, so the attachments will always be sequential so long as no other files are sporadically saved there.
[VBA]
' Renames attachment to sequential number and stores in folder
Public Sub SaveToFolder(Atm As Attachment, FilePath As String)
Dim f As Object ' Folder holding FilePath
Dim fs As Object ' FileSystemObject
Dim FileName As String ' Name to save file
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(FilePath)
FileName = Atm.FileName
' Get file extension
If InStr(FileName, ".") = 0 Then
Debug.Print "No extension"
FileName = ""
Else:
Debug.Print "Extension"
Do
FileName = Mid(FileName, InStr(FileName, ".") + 1)
Loop While InStr(FileName, ".")
FileName = "." & FileName
End If
' Create full file path
FileName = FilePath & "\" & Format(f.Files.count, "00000000") & FileName
' Save file
Debug.Print FileName
Atm.SaveAsFile FileName
End Sub
[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules