【发布时间】:2019-08-09 08:56:44
【问题描述】:
我正在处理 Excel 中的 vba 宏。 Outlook 日历中的所有会议(在给定时间段内)都被读取并写入新表中。
除存档会议外,一切正常。存档的会议有一些奇怪的属性,这些属性与未存档的会议的属性不匹配。这会导致运行时错误。
我已尝试取消归档每个会议。在我这样做之后它工作了,但由于其他人想使用我的宏,它也应该适用于存档的会议。
我确信只有在您尝试读出存档会议时才会出现问题,因为我更改了代码以跳过错误,并且每个非存档会议的行为都应如此。
我在互联网上找不到有同样问题的人,所以我在这里问这个问题。
'Here I read out of the Oulook calendar
'---------------------------------------------------'
'Create filter to restrict meetings to the start/end date
'---------------------------------------------------'
strRestriction = "[End] >= '" & _
Format$(startDate, "dd/mm/yyyy hh:mm ") & "' AND [Start] <= '" & Format$(endDate, "dd/mm/yyyy hh:mm ") & "'"
Set outlookCalendar = outlook.GetNamespace("MAPI").GetDefaultFolder(9)
Set calendarItems = outlookCalendar.items
calendarItems.IncludeRecurrences = True
calendarItems.Sort "[Start]"
nextRow = 1
Set itemsInDateRange = calendarItems.Restrict(strRestriction)
'Here I write into the excel sheet
For Each entry In itemsInDateRange
With Sheets(sheetToWriteIn)
nextRow = nextRow + 1
sumInMinutes = sumInMinutes + durationOfOneMeeting ' summs every meeting up to return a sum at the end of the programm
.Cells(nextRow, "D").Value = durationOfOneMeeting
.Cells(nextRow, "A").Value = entry.Subject
.Cells(nextRow, "B").Value = entry.start 'The error ocures here or at entry.start
.Cells(nextRow, "C").Value = entry.End
.Cells(nextRow, "E").Value = entry.Location
End If
End With
Next
当我尝试从存档的会议中获取开始日期(这对于“正常”会议非常有效)时,我得到:
Object does not support property
或
function Runtime error 438
【问题讨论】: