![]() |
|
Missing updates
Hi
I have some code that copies an appointment from one calendar to a public calendar and it works fine when I’m using 2002. When I’m using 2003 and have disabled macros, it also works fine but if I enable my macro I will miss about 5 % of all updates in my own calendar and about 10 % in the public calendar. I’m not running my macro in a class module. Could that be the reason for missing updates? If so, how much of the macro should be in the class module? Thanks. Attached you will find the coding Option Explicit Dim myOlApp As New Outlook.Application Public WithEvents CalendarItems As Outlook.Items Public WithEvents DeletedItems As Outlook.Items Public TOCFolder As Outlook.MAPIFolder Public sUser As String Public Sub Initialize_handler() sUser = "BOH " Set CalendarItems = myOlApp.GetNamespace("MAPI"). _ GetDefaultFolder(olFolderCalendar).Items Set DeletedItems = myOlApp.GetNamespace("MAPI"). _ GetDefaultFolder(olFolderDeletedItems).Items Set TOCFolder = GetFolder("Public Folders\All Public Folders…….") If TOCFolder Is Nothing Then Set TOCFolder = GetFolder("………………") End If End Sub Private Sub Application_Startup() Initialize_handler End Sub Private Sub DeletedItems_Itemadd(ByVal Item As Object) Dim OCalItem As Outlook.AppointmentItem Dim OStr As String On Error Resume Next 'MsgBox ("ItemDel") If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else OStr = "[Item]='" & Item & "'" 'MsgBox OStr Set OCalItem = TOCFolder.Items.Find("[BillingInformation]='" & Item.BillingInformation & "'") If TypeName(OCalItem) "Nothing" Then OCalItem.Delete End If End If Set OCalItem = Nothing End Sub Private Sub CalendarItems_Itemadd(ByVal Item As Object) Dim myAppt As Outlook.AppointmentItem Dim myStr As String On Error Resume Next 'MsgBox ("ItemAdd") Item.BillingInformation = Item.LastModificationTime Item.Save Set myAppt = TOCFolder.Items.Add(Outlook.OlItemType.olAppointme ntItem) myAppt = Item myAppt.Duration = Item.Duration myAppt.Sensitivity = Item.Sensitivity If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else If myAppt.Class olAppointment Then ' MsgBox myAppt.Class ' ElseIf myAppt.Sensitivity = olPrivate Then ElseIf myAppt.Duration = 240 Then Set myAppt = Nothing Set myAppt = Item.Copy If myAppt.Sensitivity olPrivate Then myAppt.Subject = sUser & Item.Subject Else myAppt.Subject = sUser & "Privat" myAppt.Location = "" End If myAppt.ReminderSet = False myAppt.Move TOCFolder End If End If Set myAppt = Nothing End Sub Private Sub CalendarItems_Itemchange(ByVal Item As Object) Dim mychgAppt As Outlook.AppointmentItem Dim OCalItem As Outlook.AppointmentItem Dim OStr As String On Error Resume Next 'MsgBox ("ItemChange") If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else OStr = "[Item]='" & Item & "'" 'MsgBox OStr Set OCalItem = TOCFolder.Items.Find("[BillingInformation]='" & Item.BillingInformation & "'") If TypeName(OCalItem) "Nothing" Then OCalItem.Delete End If Set mychgAppt = TOCFolder.Items.Add(Outlook.OlItemType.olAppointme ntItem) mychgAppt = Item mychgAppt.Duration = Item.Duration mychgAppt.Sensitivity = Item.Sensitivity If mychgAppt.Class olAppointment Then ' ElseIf mychgAppt.Sensitivity = olPrivate Then ' Set mychgAppt = Nothing ElseIf mychgAppt.Duration = 240 Then Set mychgAppt = Nothing Set mychgAppt = Item.Copy If mychgAppt.Sensitivity olPrivate Then mychgAppt.Subject = sUser & Item.Subject Else mychgAppt.Subject = sUser & "Privat" mychgAppt.Location = "" End If mychgAppt.ReminderSet = False mychgAppt.Move TOCFolder ' MsgBox "Delete" End If Set mychgAppt = Nothing End If Set mychgAppt = Nothing Set OCalItem = Nothing End Sub |
Missing updates
Hi
When I read my post, I realized it wasn't easy to understand. If I create an new appointment and save it, outlook works fine. If I open my appointment, change the start- or end-time, wait a few seconds and then close, it works fine. But if I change my appointment and close it as fast as I can, then Outlook will not fire my macro in about 5% of all attempts! Please advise. Any help would be greatly appreciated! "boh" skrev: Hi I have some code that copies an appointment from one calendar to a public calendar and it works fine when I’m using 2002. When I’m using 2003 and have disabled macros, it also works fine but if I enable my macro I will miss about 5 % of all updates in my own calendar and about 10 % in the public calendar. I’m not running my macro in a class module. Could that be the reason for missing updates? If so, how much of the macro should be in the class module? Thanks. Attached you will find the coding Option Explicit Dim myOlApp As New Outlook.Application Public WithEvents CalendarItems As Outlook.Items Public WithEvents DeletedItems As Outlook.Items Public TOCFolder As Outlook.MAPIFolder Public sUser As String Public Sub Initialize_handler() sUser = "BOH " Set CalendarItems = myOlApp.GetNamespace("MAPI"). _ GetDefaultFolder(olFolderCalendar).Items Set DeletedItems = myOlApp.GetNamespace("MAPI"). _ GetDefaultFolder(olFolderDeletedItems).Items Set TOCFolder = GetFolder("Public Folders\All Public Folders…….") If TOCFolder Is Nothing Then Set TOCFolder = GetFolder("………………") End If End Sub Private Sub Application_Startup() Initialize_handler End Sub Private Sub DeletedItems_Itemadd(ByVal Item As Object) Dim OCalItem As Outlook.AppointmentItem Dim OStr As String On Error Resume Next 'MsgBox ("ItemDel") If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else OStr = "[Item]='" & Item & "'" 'MsgBox OStr Set OCalItem = TOCFolder.Items.Find("[BillingInformation]='" & Item.BillingInformation & "'") If TypeName(OCalItem) "Nothing" Then OCalItem.Delete End If End If Set OCalItem = Nothing End Sub Private Sub CalendarItems_Itemadd(ByVal Item As Object) Dim myAppt As Outlook.AppointmentItem Dim myStr As String On Error Resume Next 'MsgBox ("ItemAdd") Item.BillingInformation = Item.LastModificationTime Item.Save Set myAppt = TOCFolder.Items.Add(Outlook.OlItemType.olAppointme ntItem) myAppt = Item myAppt.Duration = Item.Duration myAppt.Sensitivity = Item.Sensitivity If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else If myAppt.Class olAppointment Then ' MsgBox myAppt.Class ' ElseIf myAppt.Sensitivity = olPrivate Then ElseIf myAppt.Duration = 240 Then Set myAppt = Nothing Set myAppt = Item.Copy If myAppt.Sensitivity olPrivate Then myAppt.Subject = sUser & Item.Subject Else myAppt.Subject = sUser & "Privat" myAppt.Location = "" End If myAppt.ReminderSet = False myAppt.Move TOCFolder End If End If Set myAppt = Nothing End Sub Private Sub CalendarItems_Itemchange(ByVal Item As Object) Dim mychgAppt As Outlook.AppointmentItem Dim OCalItem As Outlook.AppointmentItem Dim OStr As String On Error Resume Next 'MsgBox ("ItemChange") If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else OStr = "[Item]='" & Item & "'" 'MsgBox OStr Set OCalItem = TOCFolder.Items.Find("[BillingInformation]='" & Item.BillingInformation & "'") If TypeName(OCalItem) "Nothing" Then OCalItem.Delete End If Set mychgAppt = TOCFolder.Items.Add(Outlook.OlItemType.olAppointme ntItem) mychgAppt = Item mychgAppt.Duration = Item.Duration mychgAppt.Sensitivity = Item.Sensitivity If mychgAppt.Class olAppointment Then ' ElseIf mychgAppt.Sensitivity = olPrivate Then ' Set mychgAppt = Nothing ElseIf mychgAppt.Duration = 240 Then Set mychgAppt = Nothing Set mychgAppt = Item.Copy If mychgAppt.Sensitivity olPrivate Then mychgAppt.Subject = sUser & Item.Subject Else mychgAppt.Subject = sUser & "Privat" mychgAppt.Location = "" End If mychgAppt.ReminderSet = False mychgAppt.Move TOCFolder ' MsgBox "Delete" End If Set mychgAppt = Nothing End If Set mychgAppt = Nothing Set OCalItem = Nothing End Sub |
Missing updates
If this is in Outlook VBA use the intrinsic Application object and don't set
up a new Outlook.Application object. Macros are public Subs in code modules that have no input arguments. Do you miss things when a lot of items are deleted at one time? ItemAdd, ItemRemove and ItemChange only will fire if fewer than 16 items are added/removed/changed at one time. That's a MAPI limitation that Outlook code inherits. If your macro takes a lot of time when it runs then it is conceivable that you could be missing some events. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "boh" wrote in message ... Hi I have some code that copies an appointment from one calendar to a public calendar and it works fine when I’m using 2002. When I’m using 2003 and have disabled macros, it also works fine but if I enable my macro I will miss about 5 % of all updates in my own calendar and about 10 % in the public calendar. I’m not running my macro in a class module. Could that be the reason for missing updates? If so, how much of the macro should be in the class module? Thanks. Attached you will find the coding Option Explicit Dim myOlApp As New Outlook.Application Public WithEvents CalendarItems As Outlook.Items Public WithEvents DeletedItems As Outlook.Items Public TOCFolder As Outlook.MAPIFolder Public sUser As String Public Sub Initialize_handler() sUser = "BOH " Set CalendarItems = myOlApp.GetNamespace("MAPI"). _ GetDefaultFolder(olFolderCalendar).Items Set DeletedItems = myOlApp.GetNamespace("MAPI"). _ GetDefaultFolder(olFolderDeletedItems).Items Set TOCFolder = GetFolder("Public Folders\All Public Folders…….") If TOCFolder Is Nothing Then Set TOCFolder = GetFolder("………………") End If End Sub Private Sub Application_Startup() Initialize_handler End Sub Private Sub DeletedItems_Itemadd(ByVal Item As Object) Dim OCalItem As Outlook.AppointmentItem Dim OStr As String On Error Resume Next 'MsgBox ("ItemDel") If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else OStr = "[Item]='" & Item & "'" 'MsgBox OStr Set OCalItem = TOCFolder.Items.Find("[BillingInformation]='" & Item.BillingInformation & "'") If TypeName(OCalItem) "Nothing" Then OCalItem.Delete End If End If Set OCalItem = Nothing End Sub Private Sub CalendarItems_Itemadd(ByVal Item As Object) Dim myAppt As Outlook.AppointmentItem Dim myStr As String On Error Resume Next 'MsgBox ("ItemAdd") Item.BillingInformation = Item.LastModificationTime Item.Save Set myAppt = TOCFolder.Items.Add(Outlook.OlItemType.olAppointme ntItem) myAppt = Item myAppt.Duration = Item.Duration myAppt.Sensitivity = Item.Sensitivity If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else If myAppt.Class olAppointment Then ' MsgBox myAppt.Class ' ElseIf myAppt.Sensitivity = olPrivate Then ElseIf myAppt.Duration = 240 Then Set myAppt = Nothing Set myAppt = Item.Copy If myAppt.Sensitivity olPrivate Then myAppt.Subject = sUser & Item.Subject Else myAppt.Subject = sUser & "Privat" myAppt.Location = "" End If myAppt.ReminderSet = False myAppt.Move TOCFolder End If End If Set myAppt = Nothing End Sub Private Sub CalendarItems_Itemchange(ByVal Item As Object) Dim mychgAppt As Outlook.AppointmentItem Dim OCalItem As Outlook.AppointmentItem Dim OStr As String On Error Resume Next 'MsgBox ("ItemChange") If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else OStr = "[Item]='" & Item & "'" 'MsgBox OStr Set OCalItem = TOCFolder.Items.Find("[BillingInformation]='" & Item.BillingInformation & "'") If TypeName(OCalItem) "Nothing" Then OCalItem.Delete End If Set mychgAppt = TOCFolder.Items.Add(Outlook.OlItemType.olAppointme ntItem) mychgAppt = Item mychgAppt.Duration = Item.Duration mychgAppt.Sensitivity = Item.Sensitivity If mychgAppt.Class olAppointment Then ' ElseIf mychgAppt.Sensitivity = olPrivate Then ' Set mychgAppt = Nothing ElseIf mychgAppt.Duration = 240 Then Set mychgAppt = Nothing Set mychgAppt = Item.Copy If mychgAppt.Sensitivity olPrivate Then mychgAppt.Subject = sUser & Item.Subject Else mychgAppt.Subject = sUser & "Privat" mychgAppt.Location = "" End If mychgAppt.ReminderSet = False mychgAppt.Move TOCFolder ' MsgBox "Delete" End If Set mychgAppt = Nothing End If Set mychgAppt = Nothing Set OCalItem = Nothing End Sub |
Missing updates
Hi Ken
Thanks for your answer. I have removed “Dim myOlapp As New Outlook.Application” and replaced myOlApp with Application throughout. OK? The problem is still there. I’m missing things when I click an appointment in my calendar, then move the start- or end-time and then click beside the appointment to save it. If the time between moving and clicking is less than 2 – 3 seconds, the ChangeItem event will not fire in about 5% of all attempts. I think only one item is changed at one time and none of my macros are running when the event should fire. I have used a date in the past for testing and I get “This appointment occurs in the past” in the bottom of the calendar. I think, but can’t prove it, that if I save my appointment during the time outlook is writing in the bottom of the calendar, then I will miss things?!? boh "Ken Slovak - [MVP - Outlook]" skrev: If this is in Outlook VBA use the intrinsic Application object and don't set up a new Outlook.Application object. Macros are public Subs in code modules that have no input arguments. Do you miss things when a lot of items are deleted at one time? ItemAdd, ItemRemove and ItemChange only will fire if fewer than 16 items are added/removed/changed at one time. That's a MAPI limitation that Outlook code inherits. If your macro takes a lot of time when it runs then it is conceivable that you could be missing some events. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "boh" wrote in message ... Hi I have some code that copies an appointment from one calendar to a public calendar and it works fine when I’m using 2002. When I’m using 2003 and have disabled macros, it also works fine but if I enable my macro I will miss about 5 % of all updates in my own calendar and about 10 % in the public calendar. I’m not running my macro in a class module. Could that be the reason for missing updates? If so, how much of the macro should be in the class module? Thanks. Attached you will find the coding Option Explicit Dim myOlApp As New Outlook.Application Public WithEvents CalendarItems As Outlook.Items Public WithEvents DeletedItems As Outlook.Items Public TOCFolder As Outlook.MAPIFolder Public sUser As String Public Sub Initialize_handler() sUser = "BOH " Set CalendarItems = myOlApp.GetNamespace("MAPI"). _ GetDefaultFolder(olFolderCalendar).Items Set DeletedItems = myOlApp.GetNamespace("MAPI"). _ GetDefaultFolder(olFolderDeletedItems).Items Set TOCFolder = GetFolder("Public Folders\All Public Folders…….") If TOCFolder Is Nothing Then Set TOCFolder = GetFolder("………………") End If End Sub Private Sub Application_Startup() Initialize_handler End Sub Private Sub DeletedItems_Itemadd(ByVal Item As Object) Dim OCalItem As Outlook.AppointmentItem Dim OStr As String On Error Resume Next 'MsgBox ("ItemDel") If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else OStr = "[Item]='" & Item & "'" 'MsgBox OStr Set OCalItem = TOCFolder.Items.Find("[BillingInformation]='" & Item.BillingInformation & "'") If TypeName(OCalItem) "Nothing" Then OCalItem.Delete End If End If Set OCalItem = Nothing End Sub Private Sub CalendarItems_Itemadd(ByVal Item As Object) Dim myAppt As Outlook.AppointmentItem Dim myStr As String On Error Resume Next 'MsgBox ("ItemAdd") Item.BillingInformation = Item.LastModificationTime Item.Save Set myAppt = TOCFolder.Items.Add(Outlook.OlItemType.olAppointme ntItem) myAppt = Item myAppt.Duration = Item.Duration myAppt.Sensitivity = Item.Sensitivity If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else If myAppt.Class olAppointment Then ' MsgBox myAppt.Class ' ElseIf myAppt.Sensitivity = olPrivate Then ElseIf myAppt.Duration = 240 Then Set myAppt = Nothing Set myAppt = Item.Copy If myAppt.Sensitivity olPrivate Then myAppt.Subject = sUser & Item.Subject Else myAppt.Subject = sUser & "Privat" myAppt.Location = "" End If myAppt.ReminderSet = False myAppt.Move TOCFolder End If End If Set myAppt = Nothing End Sub Private Sub CalendarItems_Itemchange(ByVal Item As Object) Dim mychgAppt As Outlook.AppointmentItem Dim OCalItem As Outlook.AppointmentItem Dim OStr As String On Error Resume Next 'MsgBox ("ItemChange") If TOCFolder Is Nothing Then MsgBox "Can´t get the folder TOC" Else OStr = "[Item]='" & Item & "'" 'MsgBox OStr Set OCalItem = TOCFolder.Items.Find("[BillingInformation]='" & Item.BillingInformation & "'") If TypeName(OCalItem) "Nothing" Then OCalItem.Delete End If Set mychgAppt = TOCFolder.Items.Add(Outlook.OlItemType.olAppointme ntItem) mychgAppt = Item mychgAppt.Duration = Item.Duration mychgAppt.Sensitivity = Item.Sensitivity If mychgAppt.Class olAppointment Then ' ElseIf mychgAppt.Sensitivity = olPrivate Then ' Set mychgAppt = Nothing ElseIf mychgAppt.Duration = 240 Then Set mychgAppt = Nothing Set mychgAppt = Item.Copy If mychgAppt.Sensitivity olPrivate Then mychgAppt.Subject = sUser & Item.Subject Else mychgAppt.Subject = sUser & "Privat" mychgAppt.Location = "" End If mychgAppt.ReminderSet = False mychgAppt.Move TOCFolder ' MsgBox "Delete" End If Set mychgAppt = Nothing End If Set mychgAppt = Nothing Set OCalItem = Nothing End Sub |
Missing updates
Using Application wouldn't solve a problem of missing events, it just uses
the trusted Application object and is a good practice for all Outlook VBA code. You should not miss events when Outlook is updating the status bar and waiting for a time between making a change and saving it should also not be a factor. I'd probably comment out all my macro code and just write a debug statement using Debug.Print to make sure the event handler was being called first. Then after that got running I'd start in on why sometimes the event was missed. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "boh" wrote in message ... Hi Ken Thanks for your answer. I have removed “Dim myOlapp As New Outlook.Application” and replaced myOlApp with Application throughout. OK? The problem is still there. I’m missing things when I click an appointment in my calendar, then move the start- or end-time and then click beside the appointment to save it. If the time between moving and clicking is less than 2 – 3 seconds, the ChangeItem event will not fire in about 5% of all attempts. I think only one item is changed at one time and none of my macros are running when the event should fire. I have used a date in the past for testing and I get “This appointment occurs in the past” in the bottom of the calendar. I think, but can’t prove it, that if I save my appointment during the time outlook is writing in the bottom of the calendar, then I will miss things?!? boh |
Missing updates
Hi Ken
I did as you said. When all my macro is comment out, I get debug prints as wanted. I can see I’m doing some mistake when moving an item around. I want to copy the item which is argument to ItemChange to the public folder, then change some objects and save the appointment in the public folder but I can’t figure out how to do. My copy stores in my local folder which means I get another ItemAdd event. Please HELP. boh "Ken Slovak - [MVP - Outlook]" skrev: Using Application wouldn't solve a problem of missing events, it just uses the trusted Application object and is a good practice for all Outlook VBA code. You should not miss events when Outlook is updating the status bar and waiting for a time between making a change and saving it should also not be a factor. I'd probably comment out all my macro code and just write a debug statement using Debug.Print to make sure the event handler was being called first. Then after that got running I'd start in on why sometimes the event was missed. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "boh" wrote in message ... Hi Ken Thanks for your answer. I have removed “Dim myOlapp As New Outlook.Application” and replaced myOlApp with Application throughout. OK? The problem is still there. I’m missing things when I click an appointment in my calendar, then move the start- or end-time and then click beside the appointment to save it. If the time between moving and clicking is less than 2 – 3 seconds, the ChangeItem event will not fire in about 5% of all attempts. I think only one item is changed at one time and none of my macros are running when the event should fire. I have used a date in the past for testing and I get “This appointment occurs in the past” in the bottom of the calendar. I think, but can’t prove it, that if I save my appointment during the time outlook is writing in the bottom of the calendar, then I will miss things?!? boh |
Missing updates
The Item.Copy function will always copy the item to the source folder of the
item. You can set up a flag that's set when you copy the item so you ignore the next change event. If you're using a lower level API such as CDO 1.21 or Redemption you can use Message.CopyTo (CDO) or Safe*Item.CopyTo or RDOMail.CopyTo (both from Redemption) to avoid the copy to the source folder. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "boh" wrote in message ... Hi Ken I did as you said. When all my macro is comment out, I get debug prints as wanted. I can see I’m doing some mistake when moving an item around. I want to copy the item which is argument to ItemChange to the public folder, then change some objects and save the appointment in the public folder but I can’t figure out how to do. My copy stores in my local folder which means I get another ItemAdd event. Please HELP. boh |
Missing updates
"Hi
I have comment out the statement "On Error Resume Next" and added a statement If Item.Class = olAppointment Then" do the stuff . It works fine the first time and Debug.Print "ItemChange Item = " & Item - "ItemChange Item = Test" but when the macro runs for the 2'nd time I get an run-time error '-2147221233 (800401f)':Automation error. I think I have to do a better check of the Item object before I use it but how? I think the appointment that fires the event is moved to the public folder during the 1'st run of the macro and thats why I get problems. Is it possible to trap a error with code? If yes, how do I do? Thanks / boh "Ken Slovak - [MVP - Outlook]" skrev: The Item.Copy function will always copy the item to the source folder of the item. You can set up a flag that's set when you copy the item so you ignore the next change event. If you're using a lower level API such as CDO 1.21 or Redemption you can use Message.CopyTo (CDO) or Safe*Item.CopyTo or RDOMail.CopyTo (both from Redemption) to avoid the copy to the source folder. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "boh" wrote in message ... Hi Ken I did as you said. When all my macro is comment out, I get debug prints as wanted. I can see I’m doing some mistake when moving an item around. I want to copy the item which is argument to ItemChange to the public folder, then change some objects and save the appointment in the public folder but I can’t figure out how to do. My copy stores in my local folder which means I get another ItemAdd event. Please HELP. boh |
Missing updates
Of course you can trap an error in code. Just use an error handler or set On
Error Resume Next and test the Err object after every operation that might throw an error. If in doubt clear the Err object before performing the operation so you know it's clear before you start. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "boh" wrote in message ... "Hi I have comment out the statement "On Error Resume Next" and added a statement If Item.Class = olAppointment Then" do the stuff . It works fine the first time and Debug.Print "ItemChange Item = " & Item - "ItemChange Item = Test" but when the macro runs for the 2'nd time I get an run-time error '-2147221233 (800401f)':Automation error. I think I have to do a better check of the Item object before I use it but how? I think the appointment that fires the event is moved to the public folder during the 1'st run of the macro and thats why I get problems. Is it possible to trap a error with code? If yes, how do I do? Thanks / boh |
Missing updates
Thanks for your answer.
I have added some tests and debug.prints but the main problem remains. If I open an appointment, change the end-time and click "Save and close" everything works fine. Always. If I open the appointment by clicking the appointment, then drag the end-time and click beside to close, then the ItemChange event will not fire every second occasion. I have never seen two consecutive updates missing. If I open the appointment after a missing update, the correct end-time shows up. As I can see, the only missing thing is: the Itemchange event will not fire! Any thoughts about what needs to be done here? Thanks / boh "Ken Slovak - [MVP - Outlook]" skrev: Of course you can trap an error in code. Just use an error handler or set On Error Resume Next and test the Err object after every operation that might throw an error. If in doubt clear the Err object before performing the operation so you know it's clear before you start. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "boh" wrote in message ... "Hi I have comment out the statement "On Error Resume Next" and added a statement If Item.Class = olAppointment Then" do the stuff . It works fine the first time and Debug.Print "ItemChange Item = " & Item - "ItemChange Item = Test" but when the macro runs for the 2'nd time I get an run-time error '-2147221233 (800401f)':Automation error. I think I have to do a better check of the Item object before I use it but how? I think the appointment that fires the event is moved to the public folder during the 1'st run of the macro and thats why I get problems. Is it possible to trap a error with code? If yes, how do I do? Thanks / boh |
All times are GMT +1. The time now is 07:04 AM. |
|
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright 2004-2006 OutlookBanter.com