I receive e-mails from a customer with multiple excel attachments. Is there a way i can open them all at once?
I receive e-mails from a customer with multiple excel attachments. Is there a way i can open them all at once?
here is some code that I put together for you, I could not test it and you could make it look better.
if you copy this to your VB editor in Outlook, then from outlook you can make this a button on a toolbar. Then after selecting an email click the button.
Sub openallattachments() Dim out_Exp As Outlook.Explorer Dim out_Sel As Outlook.Selection Dim out_mail As Outlook.MailItem Dim out_att As Outlook.Attachments Dim myShell As Object Dim i As Long Dim Att As String Dim qt As String Dim TempFilePath As String 'get the active explorer Set out_Exp = Outlook.ActiveExplorer 'get a collection of what is selected use this to make sure only one email is selected Set out_Sel = out_Exp.Selection 'or just use the first item Set out_mail = out_Sel.Item(1) TempFilePath = Environ$("Temp") & "\" Set out_att = out_mail.Attachments ' Windows Script Host Object Set myShell = CreateObject("WScript.Shell") If out_att.Count > 0 Then For i = 1 To out_att.Count 'you may want to change this or add other extensions to it. But as it is now it will only open XLS attachments If LCase(Right(out_att.Item(i).FileName, 4)) = ".xls" Then Att = out_att.Item(i).DisplayName ' delete just in case it exists from before On Error Resume Next Kill TempFilePath & Att On Error GoTo 0 qt = Chr$(34) out_att.Item(i).SaveAsFile TempFilePath & Att myShell.Run qt & TempFilePath & Att & qt End If Next i End If Set out_Exp = Nothing Set out_Sel = Nothing Set out_att = Nothing Set out_mail = Nothing Set myShell = Nothing End Sub
Well ,i joined excel forum a few days back and i am deeply thankful to guys like you darbid who take your valuable time out to help other's ......I dunno what prevents people from saying a small thank you ,but trust me there are millions like me who keep whispering thanks every single second we look at the sweet codes written by experts like your self !!!!!
Thanks a tonne ,
Humble Regards ,
Amlan Dutta
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks