M
MIchael
Hello
I have the following code for automatic journalling of new contacts.
THat means when the save button for a contact is pressed it should be
registered for jounalling
The new entry for journalling is generated if I run that part of the code
separately. But if I close the contact nothing happens. WHeres the error in
my code (code is in "DieseOutlookSitzung")
careful Im beginner
Thank you very much for help!!!
MIchael
Public WithEvents myItem As Outlook.ContactItem
'--------------------------------------------------------
Public Sub Initalize_Handler()
Const strCancelEvent = "Application-defined or object-defined error"
On Error GoTo ErrHandler
Set myItem = Application.ActiveInspector.CurrentItem
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
Set objContact = Nothing
Set objContacts = Nothing
Set objContactsFolder = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description
If Err.Description = strCancelEvent Then
MsgBox "The event was cancelled."
End If
End Sub
'--------------------------------------------------------
Private Sub myItem_Write(Cancel As Boolean)
Dim myResult As Integer
myItem = "soll dieser Kontakt im Journal geloggt werden?"
myResult = MsgBox(myItem, vbYesNo, "Save")
If myResult = vbNo Then
Cancel = True
End If
End Sub
I have the following code for automatic journalling of new contacts.
THat means when the save button for a contact is pressed it should be
registered for jounalling
The new entry for journalling is generated if I run that part of the code
separately. But if I close the contact nothing happens. WHeres the error in
my code (code is in "DieseOutlookSitzung")
careful Im beginner
Thank you very much for help!!!
MIchael
Public WithEvents myItem As Outlook.ContactItem
'--------------------------------------------------------
Public Sub Initalize_Handler()
Const strCancelEvent = "Application-defined or object-defined error"
On Error GoTo ErrHandler
Set myItem = Application.ActiveInspector.CurrentItem
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
Set objContact = Nothing
Set objContacts = Nothing
Set objContactsFolder = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description
If Err.Description = strCancelEvent Then
MsgBox "The event was cancelled."
End If
End Sub
'--------------------------------------------------------
Private Sub myItem_Write(Cancel As Boolean)
Dim myResult As Integer
myItem = "soll dieser Kontakt im Journal geloggt werden?"
myResult = MsgBox(myItem, vbYesNo, "Save")
If myResult = vbNo Then
Cancel = True
End If
End Sub