S
StuJol
Im using the following code to open the appointments window in outlook and
also transfer some data from a form into the appointment window.
This code only works if outlook is already open. Can some add some code
please to open outlook and to hide outlook.
I used the shell command when the form opened and set it to hide and it
worked fines the first time, but since the first time it wont work anymore
Thanks to anyone who looks at this for me
Private Sub cmdCreateAppt_Click()
'********************************************************************
' Name: cmdCreateAppt_Click
' Author: Arvin Meyer
' Date: June 10, 2004
' Comment: Set reference to Microsoft Outlook
'********************************************************************
On Error GoTo Err_cmdCreateAppt_Click
Dim objOl As Outlook.Application
Dim objItem As Outlook.AppointmentItem
Dim blnOlRunning As Boolean
On Error Resume Next
blnOlRunning = True
Set objOl = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set objOl = CreateObject("Outlook.Application")
blnOlRunning = False
Err.Clear
End If
On Error GoTo 0
Set objItem = objOl.CreateItem(olAppointmentItem)
With objItem
.Start = CDate(Me.txtApptDate) + CDate(Me.txtApptTime)
.Duration = Me.txtDuration * Me.ogDuration
.Subject = Me.txtSubject & vbNullString
.Body = Me.txtBody & vbNullString
If Len(Me.txtReminder & vbNullString) > 0 Then
.ReminderSet = True
.ReminderMinutesBeforeStart = Me.txtReminder * Me.ogPeriod
Else
.ReminderMinutesBeforeStart = 0
.ReminderSet = False
End If
.Save
End With
If blnOlRunning = True Then
' display the new item
objItem.Display
Else
objOl.Quit
End If
Exit_cmdCreateAppt_Click:
Set objItem = Nothing
Set objOl = Nothing
Exit Sub
Err_cmdCreateAppt_Click:
Select Case Err
Case 0
Case Else
MsgBox Err.Description
Resume Exit_cmdCreateAppt_Click
End Select
End Sub
also transfer some data from a form into the appointment window.
This code only works if outlook is already open. Can some add some code
please to open outlook and to hide outlook.
I used the shell command when the form opened and set it to hide and it
worked fines the first time, but since the first time it wont work anymore
Thanks to anyone who looks at this for me
Private Sub cmdCreateAppt_Click()
'********************************************************************
' Name: cmdCreateAppt_Click
' Author: Arvin Meyer
' Date: June 10, 2004
' Comment: Set reference to Microsoft Outlook
'********************************************************************
On Error GoTo Err_cmdCreateAppt_Click
Dim objOl As Outlook.Application
Dim objItem As Outlook.AppointmentItem
Dim blnOlRunning As Boolean
On Error Resume Next
blnOlRunning = True
Set objOl = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set objOl = CreateObject("Outlook.Application")
blnOlRunning = False
Err.Clear
End If
On Error GoTo 0
Set objItem = objOl.CreateItem(olAppointmentItem)
With objItem
.Start = CDate(Me.txtApptDate) + CDate(Me.txtApptTime)
.Duration = Me.txtDuration * Me.ogDuration
.Subject = Me.txtSubject & vbNullString
.Body = Me.txtBody & vbNullString
If Len(Me.txtReminder & vbNullString) > 0 Then
.ReminderSet = True
.ReminderMinutesBeforeStart = Me.txtReminder * Me.ogPeriod
Else
.ReminderMinutesBeforeStart = 0
.ReminderSet = False
End If
.Save
End With
If blnOlRunning = True Then
' display the new item
objItem.Display
Else
objOl.Quit
End If
Exit_cmdCreateAppt_Click:
Set objItem = Nothing
Set objOl = Nothing
Exit Sub
Err_cmdCreateAppt_Click:
Select Case Err
Case 0
Case Else
MsgBox Err.Description
Resume Exit_cmdCreateAppt_Click
End Select
End Sub