Extracting attachments and rename file names

koltregaskes

New Member
Joined
Feb 8, 2005
Messages
15
We received about 15 reports from various sources each day to our reporting mailbox. I have created Outlook VBA scripts, which are run from a message rule, to save each report from the emails to the relevant network folder (for different projects). I have a few questions on extracting and renaming the attachments:

1. How can I extract a file from an attachment with VBA to a specific folder? Example name is "report_20170831070501.zip"

2. How can I rename the file to remove the last 2 characters? Example name is report_20170831070501.csv - so would like to remove the "01", as in the seconds.

3. How can I rename the file of another report to remove the timestamp at the end of the name but keep the datestamp? Timestamp in hh-mm-ss formate, example name of report is "This Report_2017-08-31-05-41-56.xlsx".

If you need any further info from me, just shout.

Ta.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I normally use Name "this name", "to this name" to rename files and I guess it's something like left(oFile.name,2) to remove the ends but I can't figure out how to put these together to rename and remove the ends.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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