AppointmentItem Close causing error in outlook

C

csdev

I am writing an Outlook addin using Visual Basic and CDO. I am trying to
catch the write event for an appointment item, redirect the write to do some
processing of my own, and then close the appointmentItem window without
saving the changes. However, after closing the item using the call
objAppointmentItem.Close(olDiscard), I get a pop-up error in outlook that
says "Could not complete the operation. One or more parameter values are not
valid." The window does successfully close without saving the changes. If I
click OK, everything continues to work with no more errors. Also, I am able
to catch the write events of other types of items (mailItems, taskItems, etc)
and close them with no problems. Is there something I should be doing
different for appointmentItems?

Thanks!
 
K

Ken Slovak - [MVP - Outlook]

Without seeing your code and what you're doing it's impossible to know.
 
C

csdev

Here is the code I am using . . .

Private Sub objAppointmentItem_Write(Cancel As Boolean)
Dim objCurrentMessage As MAPI.message

Set objCurrentMessage = GetMessage(objAppointmentItem)

WriteTrace "Caught appointmentItem write."
Cancel = ItemWrite(objCurrentMessage)

If Cancel = True Then
objAppointmentItem.Close (olDiscard)
End If

Set objAppointmentItem = Nothing

End Sub

The ItemWrite method is shared among different item types. It checks to see
if certain conditions are true, and if they are it warns the user that the
item cannot be edited and returns True.

I hope this helps.
 
C

csdev

Also, this happens only when using Outlook 2003. If I install the same code
on Outlook 2002, it works fine, and no error message pops up.
 
K

Ken Slovak - [MVP - Outlook]

Outlook 2003 SP2 or all versions of Outlook 2003?

Things I'd try would be first to fully qualify GetMessage, but that's just
me. Then I'd release objCurrentMessage after calling ItemWrite.

I don't know about Write but I've had problems closing items like that when
in an event procedure sometimes. What works sometimes is closing the
Inspector instead of the item. Sometimes I've had to set a flag and use a
timer and close the item in the timer's event handler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top