通过Outlook预订项快速迭代 [英] Iterating quickly through Outlook appointment items
问题描述
我写了一个宏,它迭代用户日历,并对修改了某个critera的条目进行修改。
问题是,当日历非常大,这需要很长时间来做。我似乎不能过滤约会,因为 oAppointmentItems
似乎存储条目,因为他们创建 - 这不一定是相同的顺序,当他们开始。 p>
我使用的代码是:
Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oAppointments As Object
Dim oAppointmentItem As Outlook.AppointmentItem
设置oNS = oOL.GetNamespace(MAPI)
设置oAppointments = oNS.GetDefaultFolder(olFolderCalendar)
对于每个oAppointmentItem在oAppointments.Items
DoEvents
'这里的
下一个
设置oAppointmentItem =无
设置oAppointments =无
设置oNS =无
设置oOL =无任何
删除 DoEvents
(这只意味着Outlook似乎锁定用户)我可以通过应用某种过滤器来加快速度?例如,将来开始的约会。
您可以使用限制进行过滤。请注意,日期格式为月,日,年,即使存储为日期,也会将其过滤为字符串:
设置olApp = CreateObject(Outlook.Application)
设置olNS = olApp.GetNamespace(MAPI)
设置olRecItems = olNS.GetDefaultFolder(olFolderTasks)
strFilter = [DueDate]>''1/15/2009'
设置olFilterRecItems = olRecItems.Items.Restrict(strFilter)
对于i = 1到olFilterRecItems.Count
< ...>
详细信息:http://msdn.microsoft.com/en-us/library/bb220369.aspx
I've written a macro which iterates through a users calendar and makes modifications to entries that fufil a certain critera.
The problem is that when the calendar is very big, this takes a long time to do. I don't seem to be able to filter the appointments because oAppointmentItems
seems to store entries as they were created - which is not necessarily the same order as when they start.
The code I'm using is this:
Dim oOL As New Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oAppointments As Object
Dim oAppointmentItem As Outlook.AppointmentItem
Set oNS = oOL.GetNamespace("MAPI")
Set oAppointments = oNS.GetDefaultFolder(olFolderCalendar)
For Each oAppointmentItem In oAppointments.Items
DoEvents
' Something here
Next
Set oAppointmentItem = Nothing
Set oAppointments = Nothing
Set oNS = Nothing
Set oOL = Nothing
Short of removing the DoEvents
(which only means that Outlook appears to lock up to the user) is there any way I can speed this up by applying some kind of filter? For example, appointments which start in the future.
You can use Restrict to filter. Note that dates are in the format month, day, year and that they are filtered as strings, even though stored as dates:
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olRecItems = olNS.GetDefaultFolder(olFolderTasks)
strFilter = "[DueDate] > '1/15/2009'"
Set olFilterRecItems = olRecItems.Items.Restrict(strFilter)
For i = 1 To olFilterRecItems.Count
<...>
More information: http://msdn.microsoft.com/en-us/library/bb220369.aspx
这篇关于通过Outlook预订项快速迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!