|
-
Jan 27th, 2009, 12:20 PM
#1
Thread Starter
Hyperactive Member
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:
Private WithEvents objContact As Outlook.ContactItem
Private WithEvents objExplorer As Outlook.Explorer
Private WithEvents objOLApp As Outlook.Application
Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
'Set my object to the host application.
Set objOLApp = Outlook.Application
Set objExplorer = Outlook.ActiveExplorer
End Sub
Private Sub objExplorer_SelectionChange()
'Custom Function to see if current folder is a contact folder
If IsContactFolder = False Then Exit Sub
Dim objSel As Outlook.Selection
If objExplorer.Selection.Count = 1 Then
Set objSel = objExplorer.Selection
If objSel.Count = 1 Then
If TypeName(objSel.Item(1)) = "ContactItem" Then
Set objContact = objSel.Item(1)
End If
End If
End If
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|