G
Guest
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").Folders("Data
Warehouse").Folders("Public").Folders("CTS").Folders("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
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").Folders("Data
Warehouse").Folders("Public").Folders("CTS").Folders("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