private sub ContactItem_write

  • Thread starter Thread starter valib
  • Start date Start date
V

valib

I want to link some fields from Outlook to Access when a contact item i
saved. But the private sub does not start. I am only able to do thi
when I store the macro in a form using VBScript but then I am not abl
to link with Access.What do I have to do to make a macro start when
contact is saved?
Please help!
Thank
 
You can use the MAPIFolder.Items.ItemAdd and .ItemChange events with the MAPIFolder object pointing to your Contacts folder.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Thank you for your answer!
I know programmed the following:

Dim myOlApp As Outlook.Application
Public WithEvents myOlItems As Outlook.Items

Public Sub Initialize_handler()
Set myOlItems
myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
End Sub

Private Sub myOlItems_ItemChange()
If MsgBox("Sicronizar con Base de Datos?", vbYesNo + vbQuestion)
vbYes Then
'inicio de comparacion con datos del Access
End If
End Sub

why does it not work? Maybe i have to call the initialize_handle
before? If yes, how can I do this?

Thank you :-
 
What in particular doesn't work? Please take the time to quote the original message so that people reading your current response can understand what you're talking about. Otherwise, you may not receive the answer you're looking for.

This is in a class module, right? How are you instantiating the class? Yes, you definitely need to either call the Initialize_handler procedure or use code in the Class_Initialize event handler.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Thanks a lot for your help!
It simply doesnt start as I dont know how to instantiate the clas
module. I tried like this:

Dim myOlApp As Outlook.Application
Public WithEvents myOlItems As Outlook.Items


Private Sub Class_Initialize()
Set myOlItems
myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
End Sub

Private Sub myOlItems_ItemChange()
Dim myOlMItem As Outlook.MailItem
If MsgBox("Sicronizar con Base de Datos?", vbYesNo + vbQuestion)
vbYes Then
'inicio de comparacion con datos del Access
End If
End Sub

I've never worked with class modules, so how do I instantiate it?

Thanks a lot,
Val




What in particular doesn't work? Please take the time to quote the =
original message so that people reading your current response can =
understand what you're talking about. Otherwise, you may not receiv
the =
answer you're looking for.=20

This is in a class module, right? How are you instantiating the class
=
Yes, you definitely need to either call the Initialize_handle
procedure =
or use code in the Class_Initialize event handler.=20
--=20
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx=20

valib said:
=20
Thank you for your answer!
I know programmed the following:
=20
Dim myOlApp As Outlook.Application
Public WithEvents myOlItems As Outlook.Items
=20
Public Sub Initialize_handler()
Set myOlItems =3D
myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
End Sub
=20
Private Sub myOlItems_ItemChange()
If MsgBox("Sicronizar con Base de Datos?", vbYesNo + vbQuestion) =3D
vbYes Then
'inicio de comparacion con datos del Access
End If
End Sub
=20
why does it not work? Maybe i have to call the initialize_handler
before? If yes, how can I do this?
=20
Thank you :-)
=20
=20




You can use the MAPIFolder.Items.ItemAdd and .ItemChange events wit
the =
MAPIFolder object pointing to your Contacts folder.=20
--=20
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx=20
 
Context please! Is this VBA or VB?

You instantiate a new class member like this:

Dim objMyClass As New NameOfYourClass
 
This is VBA

Dim objMyClass As New NameOfYourClass

where do I have to place this? In general declarations of
myOutlooksession or in the class module itself?

thanks a lot!







Context please! Is this VBA or VB?=20

You instantiate a new class member like this:=20

Dim objMyClass As New NameOfYourClass
 
That needs to go in the ThisOutlookSession module.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Back
Top