![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi All!
I'm new to writing codes in Outlook. I need a code that looks for a date string within the filename of an email attachment. I've ask the people in the field to name their attachment with a date format of "mm-dd-yyyy". And the string can be anywhere within the filename. If the filename doesn't contain a date information in the format I need, it exits the macro. If it does, then it goes and saves the attachment to disk. Thanks in advance, Ron |
Ads |
#2
|
|||
|
|||
![]() If you can be sure, the people use the format you want to have then this might work: For i=1 to Len(text) If IsDate(Mid$(text,i, Len("mm-dd-yyyy") Then ' match Exit For Endif Next -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Fri, 15 Aug 2008 03:50:00 -0700 schrieb Ron_D: Hi All! I'm new to writing codes in Outlook. I need a code that looks for a date string within the filename of an email attachment. I've ask the people in the field to name their attachment with a date format of "mm-dd-yyyy". And the string can be anywhere within the filename. If the filename doesn't contain a date information in the format I need, it exits the macro. If it does, then it goes and saves the attachment to disk. Thanks in advance, Ron |
#3
|
|||
|
|||
![]()
Michael,
That did the trick!! Thank you for your help. I've also added a 2nd condition in the If statement. Because I can't guarrantee that the field will always name the file with the proper date format, I've amended the if statement to look like this: If IsDate(Mid$(text,i,Len("mm-dd-yyyy"))) AND Len(trim(Mid$(text,i,Len("mm-dd-yyyy"))))=Len("mm-dd-yyyy") then ' Do Stuff end if -Ron "Michael Bauer [MVP - Outlook]" wrote: If you can be sure, the people use the format you want to have then this might work: For i=1 to Len(text) If IsDate(Mid$(text,i, Len("mm-dd-yyyy") Then ' match Exit For Endif Next -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Fri, 15 Aug 2008 03:50:00 -0700 schrieb Ron_D: Hi All! I'm new to writing codes in Outlook. I need a code that looks for a date string within the filename of an email attachment. I've ask the people in the field to name their attachment with a date format of "mm-dd-yyyy". And the string can be anywhere within the filename. If the filename doesn't contain a date information in the format I need, it exits the macro. If it does, then it goes and saves the attachment to disk. Thanks in advance, Ron |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Strip illegal character from filename | ExcelLars | Outlook and VBA | 6 | May 21st 08 10:33 AM |
Change filename | Peter Marchert | Outlook and VBA | 17 | March 29th 07 10:24 PM |
filename too long error | Vic Baron | Outlook Express | 3 | August 4th 06 11:49 AM |
Search email for text string to use in filename - save email text | bsteiner | Outlook and VBA | 3 | June 1st 06 11:20 PM |
Get the CID from Attachment Filename | chris | Outlook - General Queries | 2 | February 27th 06 08:33 PM |