View Single Post
  #9  
Old February 3rd 06, 02:35 PM posted to microsoft.public.outlook.program_vba
dim4x4
external usenet poster
 
Posts: 17
Default Creating new appointment & setting its properties

Thank you, Josh!

I moved your code to the module and it works great! Also for my first
problem, I found a solution here
http://www.outlookcode.com/codedetail.aspx?id=616 and modified your
CreateTestItem as follows below. It does what I need to do, the only
minor thing is that it opens and closes an appointment which makes a
quick flicker on the screen, but I guess I can live with that. Thank
you and Ken for your help!

This is my macro (apart from other parts that put cursor where I want
it):

Sub NewCall()

Dim objExpl As Outlook.Explorer
Dim objFolder As Outlook.MAPIFolder
Dim objCB As Office.CommandBarButton
Dim objAppt As Outlook.AppointmentItem
Dim objApptCustom As Outlook.AppointmentItem
On Error Resume Next

Set objExpl = Application.ActiveExplorer
If Not objExpl Is Nothing Then
Set objFolder = objExpl.CurrentFolder
If objFolder.DefaultItemType = olAppointmentItem Then
Set objCB = objExpl.CommandBars.FindControl(, 1106)
If Not objCB Is Nothing Then
objCB.Execute
Set objAppt = Application.ActiveInspector.CurrentItem
Set objApptCustom =
objFolder.Items.Add("IPM.Appointment.your_custom_c lass")
With objApptCustom
.Subject = DEFAULT_SUBJECT
.Start = objAppt.Start
.End = objAppt.End
.Duration = 5
.ReminderMinutesBeforeStart = 0
.Display
End With
End If
End If
End If

objAppt.Close olDiscard

Set objCB = Nothing
Set objAppt = Nothing
Set objApptCustom = Nothing
Set objFolder = Nothing
Set objExpl = Nothing

'SetBodyCursorPos 5
SetTextBoxCursorPos DEFAULT_SUBJECT, 5

End Sub

Ads