View Single Post
  #5  
Old May 14th 07, 12:30 PM posted to microsoft.public.outlook.program_vba
MIchael
external usenet poster
 
Posts: 9
Default itemchange event in public (exchange) folder occurs if nothing is changed

Hello Ken,
Thats not an addin, its only code in thisoutlooksession (DieseOutlookSitzung in German:-)
I changed the program thats shelled for testing to Shell "c:\windows\system32\calc.exe"
the windows calculator. And its just the same .
If I open an contact the event is firing ;-((
But the funny thing is that not every time when I open the contact it is firing it seems to do it randomly.
the first 5 times opening any contact- not firing
2 times opening - firing
2 more times opening an other contact not firing...................

Sorry but I cant do anything with your proposal
"To debug it I'd probably set handlers on the items being changed to handle the PropertyChange event."
I am beginner :-((
Maybe you could give me an other hint what do you mean by "to set handlers"??
Thank you very much for your help!!
Michael

"Ken Slovak - [MVP - Outlook]" schrieb im Newsbeitrag ...
This is in an Outlook addin? Never instantiate an Outlook Application object in an Outlook addin. Use the inherited Application
object passed to you.

It looks to me like that program you're shelling out to does some sort of synching. If that's so that's where your change
events are probably coming from.

To debug it I'd probably set handlers on the items being changed to handle the PropertyChange event. That would at least tell
you what was being changed in the item and might provide a clue. For an event handler like that a review of the call stack is
probably useless.

--
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


"MIchael" wrote in message ...
Thank you very much for your answer Ken!
No, there is (nearly :-) no other code or anything that can make it fire. I will post everything below.
Is there any possibility to trap what makes the thing run?
ciao
Michael

Dim WithEvents objFolders As Outlook.Folders
Public WithEvents colPubCustomersItems As Outlook.Items
Public WithEvents colJournalItems As Outlook.Items
'Instantiate collection object in objOutlook Startup event
'um eays2sync anzuwerfen bei Änderung im öff Ordner

Public Sub Application_Startup()
Set objFolders = Session.GetDefaultFolder(olFolderInbox).Parent.Fol ders
Dim strFolderPath As String
strFolderPath = "Öffentliche Ordner\Alle Öffentlichen Ordner\Kontakte von AS-DA2"
Set myolapp = CreateObject("Outlook.Application")
Set myNamespace = myolapp.GetNamespace("MAPI")
Set colPubCustomersItems = myNamespace.Folders("Öffentliche Ordner").Folders("Alle Öffentlichen Ordner").Folders("Kontakte von
AS-DA2").Items
Set colCustomersItems = myNamespace.GetDefaultFolder(olFolderContacts).Ite ms
Set colJournalItems = myNamespace.GetDefaultFolder(olFolderJournal).Item s
'Alles sync beim Outlook start
Shell "C:\Programme\Easy2Sync für Outlook\E2S4Outlook.exe /syncallandexit /nosplash /Delayed:10", 0
End Sub

Private Sub colPubCustomersItems_Itemchange(ByVal Item As Object)
Dim objCont As Outlook.ContactItem
Set objCont = Item
Shell "C:\Programme\Easy2Sync für Outlook\E2S4Outlook.exe /syncandexit:kontakte_dirksen /nosplash", 0 'vbnormal
End Sub

Private Sub colJournalItems_Itemchange(ByVal Item As Object)
Dim objJour As Outlook.JournalItem
Set objJour = Item
Shell "C:\Programme\Easy2Sync für Outlook\E2S4Outlook.exe /syncandexit:journal_dirksen /nosplash", 0
End Sub

Sub objFolders_FolderChange(ByVal Folder As Outlook.MAPIFolder)
On Error GoTo ErrorHandler ' Fehlerbehandlung aktivieren.
If Folder.Name = "Kontakte" Then
Dim objContactsFolder As Outlook.MAPIFolder
Dim objContacts As Outlook.Items
Dim objContact As Object
Dim iCount As Integer

' Zu verwendenden Kontaktordner angeben
Set objContactsFolder = Session.GetDefaultFolder(olFolderContacts)
Set objContacts = objContactsFolder.Items

iCount = 0

' Änderungen verarbeiten
For Each objContact In objContacts
If TypeName(objContact) = "ContactItem" Then
If objContact.Journal = False Then
objContact.Journal = True
objContact.Save
iCount = iCount + 1
End If
End If
Next

' MsgBox "Anzahl aktualisierter Kontakte:" & Str$(iCount)

' Aufräumen
ErrorHandler:
Set objContact = Nothing
Set objContacts = Nothing
Set objContactsFolder = Nothing
Exit Sub
End If
End Sub




Ads