全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1358
推到 Plurk!
推到 Facebook!

OLE GetRecurrencePattern

缺席
cashyy
高階會員


發表:117
回覆:322
積分:212
註冊:2004-04-30

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-11-25 19:10:07 IP:59.125.xxx.xxx 訂閱
各位先進您好!小弟因為要用應用程式寫資料到Outlook裡面,參考了http://delphi.ktop.com.tw/board.php?cid=168&fid=923&tid=55190
也成功實作出來了!不過需要取得與設定行事曆裡面的「週期性」,這方面找了蠻久了,一直找不到相關的文章!
在Outlook說明裡面找到了下面一段code,但不管怎麼try都是出現「不明的名稱」等錯誤,也就是「紅色」字的地方,
應該是我不知道怎麼把「紅色」字轉成BCB code,請先進們指導一下。
        
Public Sub cmdExample()
    Dim myOlApp As Outlook.Application
    Dim myApptItem As Outlook.AppointmentItem
    Dim myRecurrPatt As Outlook.RecurrencePattern
    Dim myNamespace As Outlook.NameSpace
    Dim myFolder As Outlook.Folder
    Dim myItems As Outlook.Items
    Dim myDate As Date
    Dim myOddApptItem As Outlook.AppointmentItem
    Dim saveSubject As String
    Dim newDate As Date
    Dim myException As Outlook.Exception
    Set myOlApp = New Outlook.Application
    Set myApptItem = myOlApp.CreateItem(olAppointmentItem)
    myApptItem.Start = #2/2/2003 3:00:00 PM#
    myApptItem.End = #2/2/2003 4:00:00 PM#
    myApptItem.Subject = "Meet with Boss"
    
    'Get the recurrence pattern for this appointment
    'and set it so that this is a daily appointment
    'that begins on 2/2/03 and ends on 2/2/04
    'and save it.
    Set myRecurrPatt = myApptItem.GetRecurrencePattern
    myRecurrPatt.RecurrenceType = olRecursDaily
    myRecurrPatt.PatternStartDate = #2/2/2003#
    myRecurrPatt.PatternEndDate = #2/2/2004#
    myApptItem.Save
    
    'Access the items in the Calendar folder to locate
    'the master AppointmentItem for the new series.
    Set myNamespace = myOlApp.GetNamespace("MAPI")
    Set myFolder = myNamespace.GetDefaultFolder(olFolderCalendar)
    Set myItems = myFolder.Items
    Set myApptItem = myItems("Meet with Boss")
    
    'Get the recurrence pattern for this appointment
    'and obtain the occurrence for 3/12/03.
    myDate = #3/12/2003 3:00:00 PM#
    Set myRecurrPatt = myApptItem.GetRecurrencePattern
    Set myOddApptItem = myRecurrPatt.GetOccurrence(myDate)
     
    'Save the existing subject. Change the subject and
    'starting time for this particular appointment
    'and save it.
    saveSubject = myOddApptItem.Subject
    myOddApptItem.Subject = "Meet NEW Boss"
    newDate = #3/12/2003 3:30:00 PM#
    myOddApptItem.Start = newDate
    myOddApptItem.Save
    
    'Get the recurrence pattern for the master
    'AppointmentItem. Access the collection of
    'exceptions to the regular appointments.
    Set myRecurrPatt = myApptItem.GetRecurrencePattern
    Set myException = myRecurrPatt.Exceptions.item(1)
   
    'Display the original date, time, and subject
    'for this exception.
    MsgBox myException.OriginalDate & ": " & saveSubject        'Display the current date, time, and subject
    'for this exception.
    MsgBox myException.AppointmentItem.Start & ": " & _
    myException.AppointmentItem.Subject
End Sub
另外也發現一個網站有說明週期性的文章,把下面的code轉成BCB還是會錯誤「紅色」字的地方,其中一段code如下:
http://www.microsoft.com/taiwan/technet/scriptcenter/resources/officetips/sept05/tips0901.mspx
Const olFolderCalendar = 9    Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderCalendar)    Set colItems = objFolder.Items    strFilter = "[IsRecurring] = TRUE"    Set colFilteredItems = colItems.Restrict(strFilter)    For Each objItem In colFilteredItems
    Set objPattern = objItem.GetRecurrencePattern
    Wscript.Echo "Meeting name: " & objItem.Subject
    Wscript.Echo "Duration: " & objItem.Duration & " minutes"
    Wscript.Echo "Location: " & objItem.Location
    Wscript.Echo "Recurrence type: " & objPattern.RecurrenceType
    Wscript.Echo "Start time: " & objPattern.StartTime
    Wscript.Echo "Start date: " & objPattern.PatternStartDate
    Wscript.Echo "End date: " & objPattern.PatternEndDate
    Wscript.Echo
Next
編輯記錄
cashyy 重新編輯於 2009-11-25 19:15:05, 註解 無‧
cashyy 重新編輯於 2009-11-25 19:19:58, 註解 無‧
cashyy 重新編輯於 2009-11-25 19:24:00, 註解 無‧
cashyy
高階會員


發表:117
回覆:322
積分:212
註冊:2004-04-30

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-12-10 14:01:50 IP:59.125.xxx.xxx 訂閱
嗯嗯!都沒人回應,看來可以結案了!
系統時間:2017-10-21 20:16:55
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!