Copy Subject Line When Saving Attachment

  • Thread starter Thread starter Kris
  • Start date Start date
K

Kris

Hello,

I have a macro that I found online and modified it to my needs but I
am hitting a wall.
The macro saves an attachment from the file and names it using the
subject line. However every subject line starts the same for example
"Department - ". Is there any way when the file is saving to make sure
that isn't included in the file name?

The code I am using for that section is below.
Any help would be appreciated.
Thanks

For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
If LCase(Right(Atmt.FileName, Len(ExtString))) = LCase
(ExtString) Then
FileName = DestFolder & Item.Subject & ".csv"
Atmt.SaveAsFile FileName
I = I + 1
End If
Next Atmt
Next Item
 
The Replace() function is useful for simple parsing like that:

FileName = DestFolder & Replace(Item.Subject, "Department - ", "") &
".csv"
 
Back
Top