2017-03-08 14 views
1

私はvbaを使用してOutlook用の小さなプロジェクトに取り組んできました。究極の目標は、2人の受取人との間で予定/会議を設定し、それを1日中設定することです。それで、私は自分のカレンダーで会合を見つけ、終日のイベントではないように設定する必要があります。Outlook VBA会議の調整

私は受信者に会議を送信して、希望通りに表示できるようになりました。私が持っている悩みは、同じ会議を日付と時刻(送信時と同じ)で見つけ、終日のイベントから終日のイベントにならないように変更することです。ここまで私のコードはこれまで必要なもののために働く。

Sub Appointment() 

    Dim olApt As AppointmentItem 

    Set olApp = Outlook.Application 

    Set olApt = olApp.CreateItem(olAppointmentItem) 

    With olApt 
     .Start = #3/10/2017 4:00:00 PM# 
     .End = #3/3/1017 5:00:00 PM# 
     .MeetingStatus = olMeeting 
     .AllDayEvent = True 
     .Subject = "OOO - Test" 
     .Body = "Testing Stuff" 
     .BusyStatus = olFree 
     .ReminderSet = False 
     .RequiredAttendees = "Placeholder" & ";" & " Placeholder" 
     .Save 
     .Send 
    End With 

     Set olApt = Nothing 
     Set olApp = Nothing 

End Sub 

答えて

0

この

Function FindAppts(apptDate As Date, strSubject As String) 

Dim myDate As Date 
Dim myEnd As Date 
Dim oCalendar As Outlook.Folder 
Dim oItems As Outlook.Items 
Dim oItemsInDateRange As Outlook.Items 
Dim oFinalItems As Outlook.Items 
Dim oAppt As Outlook.AppointmentItem 
Dim strRestriction As String 

myStart = apptDate 
myEnd = DateAdd("d", 30, myStart) 

Debug.Print "Start:", myStart 
Debug.Print "End:", myEnd 

'Construct filter for the next 30-day date range 
strRestriction = "[Start] >= '" & _ 
Format$(myStart, "mm/dd/yyyy hh:mm AMPM") _ 
& "' AND [End] <= '" & _ 
Format$(myEnd, "mm/dd/yyyy hh:mm AMPM") & "'" 

'Check the restriction string 
Debug.Print strRestriction 

Set oCalendar = Application.Session.GetDefaultFolder(olFolderCalendar) 
Set oItems = oCalendar.Items 
oItems.IncludeRecurrences = False 
oItems.Sort "[Start]" 

'Restrict the Items collection for the 30-day date range 
Set oItemsInDateRange = oItems.Restrict(strRestriction) 

'Construct filter for Subject containing 'team' 
Const PropTag As String = "http://schemas.microsoft.com/mapi/proptag/" 
strRestriction = "@SQL=" & Chr(34) & PropTag _ 
    & "0x0037001E" & Chr(34) & " like '%' & strSubject & '%'" 

'Restrict the last set of filtered items for the subject 
Set oFinalItems = oItemsInDateRange.Restrict(strRestriction) 
'Sort and Debug.Print final results 
oFinalItems.Sort "[Start]" 
For Each oAppt In oFinalItems 
    Debug.Print oAppt.Start, oAppt.Subject 
    If oAppt.Start = apptDate Then 
     oAppt.Delete 
    End If 

Next 
End Function 

を試してみて、私は、Officeデベロッパーセンターからこれを変更:Search the Calendar for Appointments Within a Date Range that Contain a Specific Word in the Subject

関連する問題