Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel With Outlook

Hello,
I know it's not just an Excel issue but I am writing a Macro to get m
all the appointements I have in Outlook and import them to an Exce
Sheet.

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 = "Date"
Cells(1, 3).Formula = "With Who"
Cells(1, 4).Formula = "Where"
With Range("A1:D1").Font
.Bold = True
.Size = 14
End With
Application.Calculation = xlCalculationManual
Set OLF = GetObject("", _

"Outlook.Application").GetNamespace("MAPI").GetDef aultFolder(olFolderCalendar)
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-mai
messages " & _
Format(i / EmailItemCount, "0%") & "..."
With OLF.Items(i)
EmailCount = EmailCount + 1
Cells(EmailCount + 1, 1).Formula = .Subject
Cells(EmailCount + 1, 2).Formula = Format(.StartTime
"dd.mm.yyyy hh:mm")
Cells(EmailCount + 1, 3).Formula = .EndTime
Cells(EmailCount + 1, 4).Formula = .Attendees
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

I get Debug error in the following lines
Cells(EmailCount + 1, 2).Formula = Format(.StartTime, "dd.mm.yyy
hh:mm")
Cells(EmailCount + 1, 3).Formula = .EndTime
Cells(EmailCount + 1, 4).Formula = .Attendees

Any Idea how to Fix it!!!. Trying to get the Start and End time i
Addition to the Attendees (I need a loop but how can I loop and wha
count I need to use)
Any Help will be appreciated...
Thanks;

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Excel With Outlook

Try this

Dim sRecips As String
Dim oRecip As Recipient

With OLF.Items(i)
EmailCount = EmailCount + 1
Cells(EmailCount + 1, 1).Formula = .Subject
Cells(EmailCount + 1, 2).Formula = Format(.Start, "dd.mm.yyyy
hh:mm")
Cells(EmailCount + 1, 3).Formula = .End
For Each oRecip In OLF.Items(i).Recipients
sRecips = sRecips & oRecip.Name & ","
Next oRecip
Cells(EmailCount + 1, 4).Formula = sRecips
sRecips = ""
End With

StartTime and EndTime are not properties of AppointmentItem, they should be
Start and End. You can loop through the Recipients collection to get the
Attendees. There is no Attendees property.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"alihussain19 " wrote in
message ...
Hello,
I know it's not just an Excel issue but I am writing a Macro to get me
all the appointements I have in Outlook and import them to an Excel
Sheet.

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 = "Date"
Cells(1, 3).Formula = "With Who"
Cells(1, 4).Formula = "Where"
With Range("A1:D1").Font
Bold = True
Size = 14
End With
Application.Calculation = xlCalculationManual
Set OLF = GetObject("", _


"Outlook.Application").GetNamespace("MAPI").GetDef aultFolder(olFolderCalenda
r)
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 " & _
Format(i / EmailItemCount, "0%") & "..."
With OLF.Items(i)
EmailCount = EmailCount + 1
Cells(EmailCount + 1, 1).Formula = .Subject
Cells(EmailCount + 1, 2).Formula = Format(.StartTime,
"dd.mm.yyyy hh:mm")
Cells(EmailCount + 1, 3).Formula = .EndTime
Cells(EmailCount + 1, 4).Formula = .Attendees
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

I get Debug error in the following lines
Cells(EmailCount + 1, 2).Formula = Format(.StartTime, "dd.mm.yyyy
hh:mm")
Cells(EmailCount + 1, 3).Formula = .EndTime
Cells(EmailCount + 1, 4).Formula = .Attendees

Any Idea how to Fix it!!!. Trying to get the Start and End time in
Addition to the Attendees (I need a loop but how can I loop and what
count I need to use)
Any Help will be appreciated...
Thanks;)


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
custimized outlook today in outlook 2007 Hal Excel Discussion (Misc queries) 2 June 20th 07 12:59 AM
excel open in outlook if outlook is running kirk Excel Discussion (Misc queries) 0 May 24th 06 06:42 PM
Send to Outlook 2000 not Outlook Express Jimbo Excel Discussion (Misc queries) 2 January 4th 05 08:19 PM
Outlook 2003 demo back to Outlook XP Pete Carr Excel Discussion (Misc queries) 1 December 22nd 04 08:04 AM
Display mail application either in Outlook, or Outlook express [email protected] Excel Programming 0 April 13th 04 09:50 PM


All times are GMT +1. The time now is 03:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"