Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Home About Excel Tip Excel 2007 Tutorials Books Training Consulting Forum News Advertise with us
Ads by Google Access VBA Outlook Excel VBA Tutorial Excel Macro Excel Programming Microsof t Excel Help
CATEGORY - Applications - Word, Outlook in VBA VERSION - All Microsoft Excel Versions
Ads by Google
The two example m acros below dem onstrates how you can send inform ation to Outlook MS Excel Tips
(e.g. sending an e-mail message) and how you can retrieve information from Outlook Excel Macro
(e.g. retrieving a list av all messages in the Inbox). Sorting in Excel
Excel Form ula Help
Note! Read and edit the exam ple code before you try to execute it in your own project!
Sub ListAllItemsInInbox()
Dim OLF As Outlook.MAPIFolder, CurrUser As String
Dim EmailItemCount As Integer, i As Integer, EmailCount As Integer
Application.ScreenUpdating = False
Workbooks.Add ' create a new workbook
' add headings
Cells(1, 1).Formula = "Subject"
Cells(1, 2).Formula = "Recieved"
Cells(1, 3).Formula = "Attachments"
Cells(1, 4).Formula = "Read"
With Range("A1:D1").Font
.Bold = True
.Size = 14
End With
Application.Calculation = xlCalculationManual
Set OLF = GetObject("", _
"Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
EmailItemCount = OLF.Items.Count
i = 0: EmailCount = 0
' read e-mail information
While i < EmailItemCount
i = i + 1
If i Mod 50 = 0 Then Application.StatusBar = "Reading e-mail messages " & _
exceltip.com/show_tip/…/464.html 1/2
4/19/2011 Control Outlook from Excel using VBA i…
Format(i / EmailItemCount, "0%") & "..."
With OLF.Items(i)
EmailCount = EmailCount + 1
Cells(EmailCount + 1, 1).Formula = .Subject
Cells(EmailCount + 1, 2).Formula = Format(.ReceivedTime, "dd.mm.yyyy hh:mm")
Cells(EmailCount + 1, 3).Formula = .Attachments.Count
Cells(EmailCount + 1, 4).Formula = Not .UnRead
End With
Wend
Application.Calculation = xlCalculationAutomatic
Set OLF = Nothing
Columns("A:D").AutoFit
Range("A2").Select
ActiveWindow.FreezePanes = True
ActiveWorkbook.Saved = True
Application.StatusBar = False
End Sub
How do I set that up? I'm actually using Outlook 2003. Can I get m odified
code to work with that?
Comment Title
Comments
Copyright © 2003 ExcelTip.com Microsoft, Microsoft Excel is a U.S. registered trademark of Microsoft Corporation
exceltip.com/show_tip/…/464.html 2/2