Link to home
Start Free TrialLog in
Avatar of proltdman
proltdman

asked on

Auto save an attachment in a designated directory

I always receive the same attachment everyday at a certain time which I have to save to a particular directory. In doing so I overwrite the original document that I recived the day before. It is an updated file that we use for our intranet

Is there a way I can use a macro to auto save this attachment to the particular directory and overwriting the original?
Also bear in mind that both documents have diferent names. So in order to overwrite I always had to rename the received attachment to match the original in order for the link on the intranet to work. i.e. the original doc is called DocA.xls and the attachment comes in as DocB.xls, so I have to rename the attachement to DocA.xls and overwritting the original.

Is there a way to automate this process?
Thanks!
SOLUTION
Avatar of stefri
stefri
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of proltdman
proltdman

ASKER

Ok I wil give this a try and let you know. Thanks!
I use outlook 2003

Hi, stefri.

I'd recommend a minor change to your code.  It's possible that someone might send a message with same subject that the rule is watching for and the code would save any attachment that message had.  It's also possible that a legitimate message with the correct attachment and one or more additional attachments would arrive and the code would save them all, overwriting the file with the last attachment in line.  Both of these can be avoided by simply testing the attachment name to make sure it's the file proltdman is looking for.  Just a thought.
Perhaps I should also mention that the attached file also has the day's date appended to it. i.e DocA 24.07.06.xls, hence it comes as a different file each day, but the SUBJECT field always has the same title.
I'm not sure if this will make it any easier to code.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks BDF,
However, as I said earlier, the incoming attachment is date stamped by the sender to reflect the day of sending, hence DocB comes in as DocB 24.07.06 or DocB 25.07.06 etc etc etc!
Can I use a wild card format in the line
 If Left(Item.Attachments.Item(1).FileName, 4) = "DocB" Then
changed to
 If Left(Item.Attachments.Item(1).FileName, 4) = "DocB *" Then

or won't that work?
I guess I don't see what the problem is with the code as is.  It doesn't matter what comes after "DocB" since I'm only checking the leftmost four characters which will always be DocB.  There's no difference in checking the leftmost four characters and checking the same four characters and anything that follows, is there?  As to the syntax "DocB *" that won't work with the Left function.  It doesn't understand wildcards.
Sorry i didn't click on the "Left" function you implemented, I will try it now..
Great, it works!

I used the code from BlueDevilFan and set up the rules as suggested by stefri.

Thanks for your efforts guys, I really appareciate it.

I will split the points between you two. I know it's not much but it just shows that I value both of your efforts.

proltdman.