Save attachments with subject name
Hi, hoping this is a quick fix. I'm using this macro to save attachments as they arrive in to a mailbox. I'd like to attachments to include to subject as well as the document name. Is this possible?
Thanks
Code:
Sub FindFilesAndMove() Dim MyFolder As String, MyFile As String, srchStr As String, DestFoldFull As String, FSO As Object, rCell As Range
Dim DestFold As String
Set FSO = CreateObject("Scripting.Filesystemobject")
MyFolder = "Y:\accounts\Conv slips\" '<<< change to suit
DestFold = "Y:\accounts\Conv slips\Completions packs\"
For Each rCell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row).Cells
MyFile = Dir(MyFolder)
srchStr = rCell.Value
DestFoldFull = DestFold & srchStr & "\"
MkDir DestFoldFull
Do While MyFile <> ""
If InStr(MyFile, srchStr) Then
FSO.MoveFile Source:=MyFolder & MyFile, Destination:=DestFoldFull & MyFile
End If
MyFile = Dir
Loop
Next rCell
End Sub