A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Reading a string in the Filename



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 15th 08, 12:50 PM posted to microsoft.public.outlook.program_vba
Ron_D
external usenet poster
 
Posts: 7
Default Reading a string in the Filename

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  
Old August 15th 08, 08:16 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Reading a string in the Filename



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  
Old August 15th 08, 10:39 PM posted to microsoft.public.outlook.program_vba
Ron_D
external usenet poster
 
Posts: 7
Default Reading a string in the Filename

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 04:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.