Program Outlook from Excel 97

V

V. Roe

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
 
S

Sue Mosher [MVP-Outlook]

It's not possible to change the UI sort in OL2000. You can, however, use the
Items.Sort method to sort your olMI collection, which is more relevant.
 
V

V. Roe

Thank you
I have it working.

Sue Mosher said:
It's not possible to change the UI sort in OL2000. You can, however, use the
Items.Sort method to sort your olMI collection, which is more relevant.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top