LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default file manipulation

I have a line of code that loops through an outlook folder searching for
excel attachments

If Right(Atmt.FileName, 3) = "xls" Then

copy it to a network folder.

I noticed it was grabbing all the attachments and finally realized that it's
case sensitive....some ended with ".XLS" and weren't being captured. Is
there a way to capture all permutations of the capitalized and lower case
string "xls" without a bunch of or statements?

Thanks,

Here's the entire sub

Private Sub CTS_Attachments()

Dim appOL As New Outlook.Application

Dim Inbox As Outlook.MAPIFolder

Dim item As Object
Dim Atmt As Outlook.Attachment
Dim FileName As String
Dim i As Integer

i = 0


Set Inbox = Outlook.Application.GetNamespace("MAPI").Folders(" Public
Folders").Folders("All Public
Folders").Folders("Dallas").Folders("Groups").Fold ers("Data
Warehouse").Folders("Public").Folders("CTS").Folde rs("CTS Current")

MsgBox Inbox
If Inbox.Items.Count = 0 Then
MsgBox "There are no messages in the CTS Current Folders",
vbInformation, "Nothing Found"
Exit Sub
End If
MsgBox "There are " & Inbox.Items.Count & " Items in the " & Inbox & "
folder."


For Each item In Inbox.Items
For Each Atmt In item.Attachments
If Right(Atmt.FileName, 3) = "xls" Then
i = i + 1
FileName = "N:\Prism\Dallas\Groups\brogers\CTS_Attachments\No " & i &
Atmt.FileName
Atmt.SaveAsFile FileName
End If
Next Atmt
Next item

If i 0 Then
MsgBox "I found " & i & " attached files." _
& vbCrLf & vbCrLf & "I have saved them into the
N:\Prism\Dallas\Groups\brogers\CTS_Attachments\ folder." _
& vbCrLf & vbCrLf & "Have a nice day.", vbInformation, "Finished!"
Else
MsgBox "I didn't find any attached files in your mail.", vbInformation,
"Finished!"
End If


Set Atmt = Nothing
Set item = Nothing
Set appOL = Nothing




End Sub

--
Billy Rogers

Dallas,TX

Currently Using Office 2000
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Value manipulation Vic Excel Discussion (Misc queries) 3 April 3rd 09 03:18 PM
Create txt file with data manipulation and reorganization (macro) vertblancrouge Excel Discussion (Misc queries) 0 August 18th 08 06:58 PM
For better Performance in VBA for Excel - Strings manipulation OR Objects manipulation vmegha Excel Programming 2 December 19th 05 12:14 AM
File Manipulation Jay Excel Programming 2 October 24th 05 08:51 AM
Code for Access file manipulation from Excel Tom Urtis Excel Programming 0 July 21st 05 08:31 AM


All times are GMT +1. The time now is 09:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"