JoseC
Programmer
- Dec 11, 2001
- 18
- 0
- 0
Using the following code I found, I can read my "own" appointments for given date.
But how do I read other peoples appointments??
Application will be used by a front desk receptionist and she'll enter a name and the VB app will respond with the individual's schedule for that day.
'**********************
Sub ShowDaysAppointments()
Dim myOlApp As New Outlook.Application
Dim myAppt As AppointmentItem
Dim myNS As NameSpace
Dim myAppts As Items
Dim strTheDay As String
Dim strToday As String
Dim strMsg As String
' Get the day from the user. User can enter
' date in nearly any format.
strTheDay = _
InputBox("Enter the day for which you want " _
& "to see appointments"
' Specify the range.
strToday = "[Start] >= '" & strTheDay & _
"' and [Start] < '" & strTheDay & " 11:59 pm'"
' Get user's appointments from Calendar folder.
Set myNS = myOlApp.GetNamespace("MAPI"
Set myAppts = myNS.GetDefaultFolder(olFolderCalendar).Items
'Sort the collection (required by IncludeRecurrences).
myAppts.Sort "[Start]"
'Make sure recurring appointments are included.
myAppts.IncludeRecurrences = True
'Filter the collection to include only the day's appointments.
Set myAppts = myAppts.Restrict(strToday)
'Sort it again to put recurring appointments in correct order.
myAppts.Sort "[Start]"
'Loop through collection and get subject and
'start time of each item.
Set myAppt = myAppts.GetFirst
Do While TypeName(myAppt) <> "Nothing"
strMsg = strMsg & vbLf & myAppt.Subject
strMsg = strMsg & " at " & Format(myAppt.Start, "h:mm ampm"
strMsg = strMsg & " till " & Format(myAppt.End, "h:mm ampm" 'JC added.
Set myAppt = myAppts.GetNext
Loop
' Display the information.
MsgBox "Your appointments for " & strTheDay & " are " _
& vbLf & strMsg
Set myOlApp = Nothing
Set myAppt = Nothing
Set myNS = Nothing
Set myAppts = Nothing
End Sub
'**********************
Thanks!
But how do I read other peoples appointments??
Application will be used by a front desk receptionist and she'll enter a name and the VB app will respond with the individual's schedule for that day.
'**********************
Sub ShowDaysAppointments()
Dim myOlApp As New Outlook.Application
Dim myAppt As AppointmentItem
Dim myNS As NameSpace
Dim myAppts As Items
Dim strTheDay As String
Dim strToday As String
Dim strMsg As String
' Get the day from the user. User can enter
' date in nearly any format.
strTheDay = _
InputBox("Enter the day for which you want " _
& "to see appointments"
' Specify the range.
strToday = "[Start] >= '" & strTheDay & _
"' and [Start] < '" & strTheDay & " 11:59 pm'"
' Get user's appointments from Calendar folder.
Set myNS = myOlApp.GetNamespace("MAPI"
Set myAppts = myNS.GetDefaultFolder(olFolderCalendar).Items
'Sort the collection (required by IncludeRecurrences).
myAppts.Sort "[Start]"
'Make sure recurring appointments are included.
myAppts.IncludeRecurrences = True
'Filter the collection to include only the day's appointments.
Set myAppts = myAppts.Restrict(strToday)
'Sort it again to put recurring appointments in correct order.
myAppts.Sort "[Start]"
'Loop through collection and get subject and
'start time of each item.
Set myAppt = myAppts.GetFirst
Do While TypeName(myAppt) <> "Nothing"
strMsg = strMsg & vbLf & myAppt.Subject
strMsg = strMsg & " at " & Format(myAppt.Start, "h:mm ampm"
strMsg = strMsg & " till " & Format(myAppt.End, "h:mm ampm" 'JC added.
Set myAppt = myAppts.GetNext
Loop
' Display the information.
MsgBox "Your appointments for " & strTheDay & " are " _
& vbLf & strMsg
Set myOlApp = Nothing
Set myAppt = Nothing
Set myNS = Nothing
Set myAppts = Nothing
End Sub
'**********************
Thanks!