VBA Excel/Outlook - Auto save attachment

natheplas

Board Regular
Joined
Aug 28, 2016
Messages
97
Hi All,

The premise I'm struggling with is to save excel attachments to folders on my PC automatically, but using a rule that looks for specific words in attachments, saves them to different folder locations.

For example test in subject, in email 1, would send it to folder1. Then test2 in subject, in email 2, would send it to folder2.

I've found a useful VBA online and changed it slightly to work with my data, it works perfectly, but I can only get it to work for 1 subject/folder.

I need 3 different subject words in the email, starting a rule to run a script, to send each attachment t different folders.

The moment I add a second module in VBA I can't see any of the scripts.

Or if I add another script, below the first one, but change the file directory it stops working.

Please see the VBA below and can someone tell me what I am doing wrong?!

Thanks in advance for any help offered.


Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "MY FOLDER LOCATION"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "" & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi All,

Figured out where I was going wrong! I had the same script name for each script.....Captain Obvious!
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top