Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using Outlook 2000 with Excel 97
I have been experimenting with code found at http://www.dicks-clicks.com/excel/olAutomating.htm I use the code to loop through emails in the Inbox, save the attachment, run code to paste information into two workbooks, and then move the email to another folder. My modified code is working, but now I need to make sure that the emails in the inbox are grouped by subject before saving the attachments (the emails must be processed in date order and the date is part of the subject line). Several people use this machine and can change the grouping. I would appreciate any help if it is possible to change the grouping in Outlook from code in excel. I have also listed the code I am using below. Thanks Valerie Sub OpenAttachment() 'My testing to open the attachment and run macro then 'move to another folder Application.EnableEvents = False Dim olApp As Outlook.Application Dim olNs As NameSpace Dim Fldr As MAPIFolder Dim MoveToFldr As MAPIFolder Dim olMi As MailItem Dim olAtt As Attachment Dim MyPath As String Dim i As Long Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") Set Fldr = olNs.GetDefaultFolder(olFolderInbox) Set MoveToFldr = Fldr.Folders("Daily Sales") MyPath = "C:\My Documents\Test\Daily Sales.xls" For i = Fldr.Items.Count To 1 Step -1 Set olMi = Fldr.Items(i) If olMi.Subject Like ("Daily Sales *") Then For Each olAtt In olMi.Attachments If olAtt.FileName = "Store Register Email v20.xls" Then olAtt.SaveAsFile MyPath Workbooks.Open FileName:=MyPath 'calls macro that copies information to correct workbooks Call ToDailyRegister End If Next olAtt olMi.Save olMi.Move MoveToFldr End If Next i Kill MyPath Set olAtt = Nothing Set olMi = Nothing Set Fldr = Nothing Set MoveToFldr = Nothing Set olNs = Nothing Set olApp = Nothing Application.EnableEvents = True End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel question borderline programing | New Users to Excel | |||
excel programing | Excel Discussion (Misc queries) | |||
Excel Programing / VBE - Good Books? | Excel Programming | |||
help with excel programing | Excel Programming | |||
Excel Programing Resources | Excel Programming |