On Wed, 31 May 2017 08:56:01 -0700 (PDT),
evets....@gmail.com
wrote:
I have made a similar macro at work for saving attachments but since
I am home I will gve you a thought from memory.
Look at the VBA FileSystemObject in Outlook help
Set fs = CreateObject("Scripting.FileSystemObject")
once you create an object out of the filesystem, you can then use the
FileExists method to test your proposed attachment file name before
you save it. if the file exists then you increment and test again
it appears that "strFile" is your proposed path and filename. Try
this:
x=1
do until fs.FileExists(strFile)=false
x=x+1
strfile=strfile & str(x)
loop
objAttachments.Item(i).SaveAsFile strFile
if the FALSE condition exists this ought to drop thru the loop and
allow you to save the file with the first choice of filename and if
that already exists (TRUE) then the increment occurs and tests again.
once the fileexists is FALSE then you can use that filename with
impunity.
There is also a folderexists method you can use to precheck the
existence of a directory, although fileexists can handle full file
names and paths.
quick and dirty
hope it helps.
depressed