sorry I had a typo, should have been:
StrTemp=Dir("C:\processed files\my message.msg" )
if StrTemp<>"" then msgbox("You have a duplicate")
Main Topics
Browse All TopicsHi
I am using Excel to produce an e-mail register and move some outlook files around& they are *.msg files
First step is I will drag the files from outlook and put them into a "to be processed" folder, any files that have the same name are renamed automatically
e.g.
I may have 3 e-mails all with the title
my message.msg
when I drag them into my "to be processed" folder they are automatically re-named
my message.msg
my message(1).msg
my message(2).msg
So far so good& I then want to open the files and do some work with them and then move them to another folder called "processed files"
Again that's fine.
The problem I have is that if I want to do the same with another batch of files at a later time then the new set of files may have the same names when they are in the "to be processed" folder e.g
my message.msg
my message(1).msg
my message(2).msg
we can live with that thenbecause the folder will have been empty but when they are moved into the "processed files" folder there will be a clash of file names.
So to recap,
I need a bit of code that checks to see if a file called ..... lets say ....."my message.msg" exists in a specified folder.
If it does then check if any other files by the same name exist....."my message(1).msg" or "my message(2).msg" or "my message(6).msg"
Work out what the new name for the file will be & in this case it would be "my message(7).msg"
I will write the rest of the code around this bit if someone can help me out with this
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi David
Couple of points there.
First isnt there a possibility that you could have two e-mails with the same date and time if you reply to someone as soon as a mail is received or would the date and time include seconds?
How would yo udo that anyway?
Secondly the code will check if the file alreay exists but its not looking for the highest varient of the file in the folder. There could be several files with the same name but different numbers ......"my message(1).msg" or "my message(2).msg" or "my message(6).msg"
Thanks
To answer your 1st question, It is possible but, it does include seconds.
You can use a funtion like this to extract the date.
Function ShowDateCreated(filespec)
Dim fso, f
Set fso = CreateObject("Scripting.Fi
Set f = fso.GetFile(filespec)
ShowDateCreated = f.DateCreated
End Function
Your second question is a little more difficult.
I will work on it if you think there might be a mesage with the same datetime.
-david251
You can use the function ftnNameCount to count the number of instances of a name
You need to pass the folename like this:
ftnNameCount("C:\processed
The asterisk will is a wildcard character.
The result of the function is the number of files matching the strFilename value.
Then append the result to the filename
-David251
Business Accounts
Answer for Membership
by: david251Posted on 2009-04-03 at 07:58:54ID: 24060639
Gordon,
I found the simplest way to accommodate this is for it not to happen, so I append the date and time to the filename.
However to do a check in the "processed files" folder you can use this
StrTemp=Dir("C:\processed files\my message.msg" )
if StrTemp="" then msgbox("You have a duplicate")
HTH,
-David251