![]() |
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 |
file manipulation
If ucase(Right(Atmt.FileName, 3)) = "XLS" Then
-- HTH... Jim Thomlinson "BillyRogers" wrote: 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 |
All times are GMT +1. The time now is 10:10 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com