Article ID: 149078
Article Last Modified on 1/19/2007
Table: Conference Sessions
--------------------------
Field Name: Session
Data Type: Text
Field Name: Date
Data Type: Text
Field Name: Start Time
Data Type: Text
Field Name: End Time
Data Type: Text
Session Date Start Time End Time
---------------------------------------------------------------------
DMT408:Distributing Access Applications 4/16/96 11:30 AM 1:00 PM
OFC307:Overview of Office Object Models 4/16/96 9:30 AM 11:30 AM
OFC401:Performance Optimization 4/17/96 2:30 PM 4:30 PM
OFC406:Access External Data 4/18/96 11:30 AM 1:00 PM
Name: AddAppt
Caption: Add Appointments
OnClick: =AddAppts()
Function AddAppts()
On Error GoTo Command1_Click_error
Dim objApp As Object, objSched As Object
Dim objTable As Object, objItem As Object
Dim db As DATABASE, rs As Recordset, i As Integer, UserName As _
String
Dim startDateTime As Variant, endTime As Variant, apptText As _
Variant
' Connect to Schedule+ and check if user is logged on or not
' logged on.
Set objApp = CreateObject("SchedulePlus.Application")
If Not objApp.LoggedOn Then
UserName = InputBox("Please enter your profile name." & _
Chr(13) & Chr(13) & "Example: Nancy Davolio")
If UserName = "" Then
Set objApp = Nothing
Exit Function
End If
objApp.Logon UserName, " ", True
End If
Set objSched = objApp.ScheduleLogged
Set objTable = objSched.SingleAppointments
' Create a recordset from the Conference Sessions table.
Set db = CurrentDb()
Set rs = db.OpenRecordset("Conference Sessions")
' Loop through recordset and retrieve values for appointments.
For i = 0 To rs.RecordCount - 1
startDateTime = rs!Date & " " & rs![start time]
endTime = rs!Date & " " & rs![end time]
apptText = rs!session
' Create a new appointment and set its properties.
Set objItem = objTable.New
objItem.SetProperties Text:=apptText, _
BusyType:=CLng(1), Start:=CDate(startDateTime), _
End:=CDate(endTime)
rs.MoveNext
Next I
' Log off Schedule+ and release the objects.
objApp.logoff
Set objApp = Nothing
Set objSched = Nothing
Set objItem = Nothing
Set objTable = Nothing
MsgBox i & " appointments were added to Schedule+."
Exit Function
Command1_Click_error:
If Err = -2147221229 Or Err = 5 Or Err = 3270 Then
MsgBox "Operation canceled."
Else
MsgBox "Error: " & Err & " " & Error
End if
Exit Function
End Function
160502 ACC: Using Automation to Add Appointments to Microsoft Outlook
Additional query words: OLE
Keywords: kbhowto kbinterop kbprogramming KB149078