2017-07-12 3 views
0

My OutlookカレンダーでAPPOINTMENTSのシリーズとその変更方法を見つけるにはどうすればよいですか?VBAで一連の予定を変更する

次のコードを使用して、1つのアポイント/会議を検索して変更します。

Private Sub ChangeAppointment(SearchDate As String, SearchApptSubject As String)   

    'SearchDate = "7/12/2017" 
    'SearchApptSubject = "Leave Office!" 

    Dim oOL As New Outlook.Application 
    Dim oNS As Outlook.NameSpace 
    Dim oAppointments As Object 
    Dim oAppointmentItem As Outlook.AppointmentItem 
    Dim ItemDate As String 
    Dim strSubject As String, strBody As String 

    Set oNS = oOL.GetNamespace("MAPI") 
    Set oAppointments = oNS.GetDefaultFolder(olFolderCalendar) 

    For Each oAppointmentItem In oAppointments.Items 

     ItemDate = Format(oAppointmentItem.Start, "mm/dd/yy") 
     ItemSubject = oAppointmentItem.Subject 

     If SearchDate = ItemDate And SearchApptSubject = ItemSubject Then 'Check all events on current date. 

      oAppointmentItem.Start = cdate("7/12/2017 6:00 PM") 
      oAppointmentItem.END = cdate("7/12/2017 6:01 PM") 
      oAppointmentItem.Subject = 'Time to go home!'     
      oAppointmentItem.Save 

      Exit For 

     End If 

    Next 

End Sub 

しかし、シリーズの一部である予定を見つけようとすると、コードはそれを見つけられません。私はシリーズで予定を見つける方法と、そのシリーズでただ1つの予定を変更する方法を知りたいと思います。前もって感謝します!

答えて

0

最初に、Sortの呼び出しで何もしないコードを作成します。使用しない一時オブジェクト(コンパイラによって作成された暗黙の変数)に対してSortを呼び出します。
第二に、あなたはIncludeRecurrencesプロパティを設定し、10コレクションを制限する必要がある(https://msdn.microsoft.com/VBA/Outlook-VBA/articles/items-includerecurrences-property-outlookを参照)

dim oItems = oAppointments.Items 
    oItems.Sort ("[Start]") 
    oItems.Restrict("[Start] > '01-01-2017' AND ("[Start] < '01-07-2017' ") 
    For Each oAppointmentItem In oItems 
     ... 
関連する問題