Results 1 to 1 of 1

Thread: Capturing Contact Create or Open Event - Is There a Better Way?

  1. #1

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Question Capturing Contact Create or Open Event - Is There a Better Way?

    Hi all,

    This is for an Outlook Add-in using Visual Basic 6.

    I'm trying to capture when a contact is opened, created, or saved. Let's just go with opened for now, however.

    I have the following code which works, but I'm wondering if there is a better way to do this.

    The following code is in the Connect.dsr of the add-in project.

    VB6 Code:
    1. Private WithEvents objContact As Outlook.ContactItem
    2. Private WithEvents objExplorer As Outlook.Explorer
    3.  
    4. Private WithEvents objOLApp As Outlook.Application
    5.  
    6. Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
    7.             ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
    8.             ByVal AddInInst As Object, custom() As Variant)
    9.  
    10.    'Set my object to the host application.
    11.    Set objOLApp = Outlook.Application
    12.    Set objExplorer = Outlook.ActiveExplorer
    13. End Sub
    14.  
    15. Private Sub objExplorer_SelectionChange()
    16.  
    17.     'Custom Function to see if current folder is a contact folder
    18.     If IsContactFolder = False Then Exit Sub
    19.    
    20.     Dim objSel As Outlook.Selection
    21.    
    22.     If objExplorer.Selection.Count = 1 Then
    23.         Set objSel = objExplorer.Selection
    24.         If objSel.Count = 1 Then
    25.             If TypeName(objSel.Item(1)) = "ContactItem" Then
    26.             Set objContact = objSel.Item(1)
    27.             End If
    28.         End If
    29.     End If
    30.    
    31. End Sub

    If there is a better way to do this, please respond. I'd greatly appreciate it.

    Actually, if this is the best way, please confirm that it is so I can move on.

    Thanks,
    JB
    Last edited by JazzBass; Jan 27th, 2009 at 04:48 PM.
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width