View Single Post
  #6  
Old August 18th 06, 10:33 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default howto check if there already are an appointment on day/time

Sorry about the delay in getting back to you. What happens if you let the Msg strFind statement run? My guess is that the problem is in how you're supplying the dates, and that should confirm it.

Also, it really helps to get your question answered faster if you post only the code that is obviously directly relevant to the issue.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"StoltHD" wrote in message ...
I know this is a heavy not good written macro, but i'm a still much to learn
novice and have done what works first and then I will clean it up later...
main issue are to get it working...
need the restrictions so i don't get any out of data range errors and more...
the script shall create appointments from (new)e-mail, check if there
already any items that match, change if so, else create a new item... if
there already an appointment in the timespan, It shall send a e-mail and
create some kind of warning (not finnished).
hopefully you can read it.... some text are norwegian but not the code itself.

best regards

snip
Set myOlApp = CreateObject("Outlook.Application")
Set mpfCalendar =
myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderCalendar)

Set colcal = mpfCalendar.Items
stDateSp = "01.01." & Year(Date)
endDateSp = "31.12. " & Year(Date)
Set restrCalendar = DateSpan(colcal, stDateSp, endDateSp)


snip


Function DateSpan(colItems As Outlook.Items, _
dteStart As Date, dteEnd As Date) _
As Outlook.Items
Dim colSpanItems As Outlook.Items
On Error Resume Next
colItems.Sort "[Start]"
colItems.IncludeRecurrences = True
strFind = "[Start] = " & _
Quote(Format(dteEnd, "ddddd") & " 11:59 PM") & _
" AND [End] " & _
Quote(Format(dteStart, "ddddd") & " 12:00 AM")
'MsgBox strFind
Set colSpanItems = colItems.Restrict(strFind)
If Err = 0 Then
Set DateSpan = colSpanItems
End If
Set colSpanItems = Nothing
End Function

Ads