The code below might get you started.
A few comments...
The code should be placed into a module in the
Outlook <acronym title="visual basic for applications">VBA</acronym> Project window;
Set a reference to the Microsoft Excel 14.0 Object Library;
Set a reference to the Microsoft Outlook 14.0 Object Library;
To set the trigger:
[TABLE="class: cms_table, width: 716"]
<tbody>[TR]
[TD] 1. Click on Rules / Create Rule / Advanced Options…[/TD]
[/TR]
[TR]
[TD] 2. Checkmark "with specific words in the message header" [enter Report][/TD]
[/TR]
[TR]
[TD] 3. Checkmark "run a script" [select Project1.UponMailReceipt][/TD]
[/TR]
[TR]
[TD] 4. Finish[/TD]
[/TR]
</tbody>[/TABLE]
Code:
Sub UponMailReceipt(myItem As Outlook.MailItem)
'Set reference to Microsoft Outlook 14.0 Object Library
'Set reference to Microsoft Excel 14.0 Object Library
Dim myNameSpace As NameSpace
Dim myFolder As Folder
Dim myAttachment As Outlook.Attachment
Dim xlApp As Object
Dim xlWB As Object
Dim xlWB2 As Object
Const File_Path As String = "C:\Temp\"
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If xlApp Is Nothing Then Set xlApp = CreateObject("Excel.Application")
On Error GoTo 0
xlApp.Visible = True
For Each myAttachment In myItem.Attachments
If InStr(myAttachment.DisplayName, "Detail") > 0 Then
myAttachment.SaveAsFile File_Path & myAttachment.FileName
Set xlWB = xlApp.Workbooks.Open(File_Path & myAttachment.FileName)
End If
Next myAttachment
On Error Resume Next
Set xlWB2 = xlApp.Workbooks("yourfilename.xlsm") 'Replace yourfilename with the name of your macro workbook
If xlWB2 Is Nothing Then Set xlWB2 = xlApp.Workbooks.Open("C:\yourpath\yourfilename.xlsm") 'Replace yourpath with the path to your macro workbook
On Error GoTo 0
End Sub
So, when you receive an email with the word Report in the subject, the macro will open Excel (if it's not already open), open the mail attachment that starts with the word Detail (if it exists), then open your macro workbook (if it's not already open). You'll need to add an event or trigger to start your macro (eg, Private Sub Workbook_Open()).
Cheers,
tonyyy