L
Lori
Hi!
I'm working with an outlook add-in for Outlook 2003 and running into
some problems with contact items. For example, if I open Contact1 and
click on my add-in button I get the right information on my form for
Contact1. When I open Contact2 and click on the add-in button I get
information regarding contact2. However, when I go back
to Contact1 and click on the add-in button, I get information for
Contact2.
Dim WithEvents m_olContactItem As Outlook.ContactItem
'Creation fo the add-in button
Dim l_oCI As Outlook.ContactItem
Dim l_cbStandard As CommandBar
l_oCI = CType(i_oItem, Outlook.ContactItem)
l_cbStandard = l_oCI.GetInspector.CommandBars("Standard")
Dim WithEvents CBBSearchContact As CommandBarButton
'Add button to toolbar
CBBSearchContact =
CType(l_cbStandard.Controls.Add(Type:=MsoControlType.msoControlButton,
_
Parameter:="Get Contact", Before:=3, Temporary:=True),
CommandBarButton)
Private Sub m_olInspectors_NewInspector(ByVal i_oInspector As
Outlook.Inspector) Handles m_olInspectors.NewInspector
Try
m_olInspector = CType(i_oInspector, Outlook.InspectorClass)
If TypeOf i_oInspector.CurrentItem Is Outlook.MailItem Then
'Must cast to MailItemClass due to "ambiguous name" problem
' m_olMailItem = CType(i_oInspector.CurrentItem,
Outlook.MailItemClass)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.PostItem Then
m_olPostItem = CType(i_oInspector.CurrentItem,
Outlook.PostItem)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.AppointmentItem
Then
m_olAppointmentItem = CType(i_oInspector.CurrentItem,
Outlook.AppointmentItem)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.ContactItem
Then
m_olContactItem = CType(i_oInspector.CurrentItem,
Outlook.ContactItem)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.DistListItem
Then
m_olDistListItem = CType(i_oInspector.CurrentItem,
Outlook.DistListItem)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.JournalItem
Then
m_olJournalItem = CType(i_oInspector.CurrentItem,
Outlook.JournalItem)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.TaskItem Then
m_olTaskItem = CType(i_oInspector.CurrentItem,
Outlook.TaskItem)
End If
Catch ex As SystemException
MsgBox(m_sDEFAULT_ERROR_MESSAGE & "Source = " & m_sModName &
".m_olInspectors_NewInspector. Message = " & ex.Message,
MsgBoxStyle.Exclamation, Err.Source)
End Try
End Sub
My code for my add-in click event is as follows:
Private Sub CBBSearchContact_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles CBBSearchContact.Click
Dim frmAnyForm As Windows.Forms.Form
Try
'send m_olContactItem is created
Dim contactSearch As New ContactFrame(m_olContactItem)
contactSearch .ShowDialog()
Catch ex As System.Exception
MsgBox("Error:" & ex.Message, MsgBoxStyle.Exclamation,
m_sADDIN_NAME)
End Try
End Sub
Any help would be appreciated.
Thanks in advance.
/Lori
I'm working with an outlook add-in for Outlook 2003 and running into
some problems with contact items. For example, if I open Contact1 and
click on my add-in button I get the right information on my form for
Contact1. When I open Contact2 and click on the add-in button I get
information regarding contact2. However, when I go back
to Contact1 and click on the add-in button, I get information for
Contact2.
Dim WithEvents m_olContactItem As Outlook.ContactItem
'Creation fo the add-in button
Dim l_oCI As Outlook.ContactItem
Dim l_cbStandard As CommandBar
l_oCI = CType(i_oItem, Outlook.ContactItem)
l_cbStandard = l_oCI.GetInspector.CommandBars("Standard")
Dim WithEvents CBBSearchContact As CommandBarButton
'Add button to toolbar
CBBSearchContact =
CType(l_cbStandard.Controls.Add(Type:=MsoControlType.msoControlButton,
_
Parameter:="Get Contact", Before:=3, Temporary:=True),
CommandBarButton)
Private Sub m_olInspectors_NewInspector(ByVal i_oInspector As
Outlook.Inspector) Handles m_olInspectors.NewInspector
Try
m_olInspector = CType(i_oInspector, Outlook.InspectorClass)
If TypeOf i_oInspector.CurrentItem Is Outlook.MailItem Then
'Must cast to MailItemClass due to "ambiguous name" problem
' m_olMailItem = CType(i_oInspector.CurrentItem,
Outlook.MailItemClass)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.PostItem Then
m_olPostItem = CType(i_oInspector.CurrentItem,
Outlook.PostItem)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.AppointmentItem
Then
m_olAppointmentItem = CType(i_oInspector.CurrentItem,
Outlook.AppointmentItem)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.ContactItem
Then
m_olContactItem = CType(i_oInspector.CurrentItem,
Outlook.ContactItem)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.DistListItem
Then
m_olDistListItem = CType(i_oInspector.CurrentItem,
Outlook.DistListItem)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.JournalItem
Then
m_olJournalItem = CType(i_oInspector.CurrentItem,
Outlook.JournalItem)
ElseIf TypeOf i_oInspector.CurrentItem Is Outlook.TaskItem Then
m_olTaskItem = CType(i_oInspector.CurrentItem,
Outlook.TaskItem)
End If
Catch ex As SystemException
MsgBox(m_sDEFAULT_ERROR_MESSAGE & "Source = " & m_sModName &
".m_olInspectors_NewInspector. Message = " & ex.Message,
MsgBoxStyle.Exclamation, Err.Source)
End Try
End Sub
My code for my add-in click event is as follows:
Private Sub CBBSearchContact_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles CBBSearchContact.Click
Dim frmAnyForm As Windows.Forms.Form
Try
'send m_olContactItem is created
Dim contactSearch As New ContactFrame(m_olContactItem)
contactSearch .ShowDialog()
Catch ex As System.Exception
MsgBox("Error:" & ex.Message, MsgBoxStyle.Exclamation,
m_sADDIN_NAME)
End Try
End Sub
Any help would be appreciated.
Thanks in advance.
/Lori