我想更改 Outlook 2010 日历中所有项目的时区。
我对在循环中迭代时如何处理集合中的项目感到困惑。我的主要背景是Java,据我所知,循环中有一个变量用作虚拟变量,它将依次获取集合中所有项目的值。这种 FOR 循环通常不需要特殊分配。您是否需要以某种方式手动推进变量以保持循环继续进行?
这是我的代码:
Public Sub TZFix()
Dim oAppointmentItem As Outlook.AppointmentItem
Dim tzs As Outlook.TimeZones
Dim tzCentral As Outlook.TimeZone
Dim oAppointments As Object
Dim oNS As Outlook.NameSpace
Set oNS = oOutlook.GetNamespace("MAPI")
Set oAppointments = oNS.GetDefaultFolder(olFolderCalendar)
Set tzs = Application.TimeZones
Set tzCentral = tzs("Central Standard Time")
For Each oAppointmentItem In oAppointments.Items
Set oAppointmentItem.StartTimeZone = tzCentral
Set oAppointmentItem.EndTimeZone = tzCentral
Next
End Sub
我相信循环中的变量分配存在问题,因为Error 91: Object Variable or With block variable not set
每当我运行它时都会出错。