Copy Subject Line When Saving Attachment

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
 
S

Sue Mosher [MVP]

The Replace() function is useful for simple parsing like that:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top