S
sd
Hello
I've VSTO SE Addin for OL2007.I've adjoined form region to standard
Appointment form.I've placed AX Ctrl built using vb6 on that form
region.It prompts me for save even though I didn't make any change.The
AX Ctrl contains 2 combos.In combo change & click I'm calling
AddModifyUserProp which adds or modifies userprop value.B'coz of
addition/Modification of userprop values it may be prompting for
save,but once userprop gets added it should not prompt for save.but I
always get save prompt whenever I open existing item ,changes combo
contents & for save prompt I says no ,reopens same item & closes the
item without any change.Now though no change,it prompts me for
save.Below is the code-
AX Ctrl-
Public Sub AddModifyUserProp(ByVal PropName As String, ByVal PropValue
As String)
Set ObjAppointmentItem = ActiveInspector.CurrentItem
If Not ObjAppointmentItem Is Nothing Then
Dim userProperty As Outlook.userProperty
Set userProperty =
ObjAppointmentItem.UserProperties.Find(PropName, True)
If userProperty Is Nothing Then
Set userProperty =
ObjAppointmentItem.UserProperties.Add(PropName, olText, True)
End If
userProperty.Value = PropValue
Set ObjAppointmentItem = Nothing
End If
End Sub
ComposeAppoinmentFormRegionWrapper.vb -
Class ComposeAppoinmentFormRegionWrapper
Inherits BaseFormRegionWrapper
Private m_Application As Outlook.Application
Private WithEvents m_Items As Outlook.Items
Shadows WithEvents FormRegion As Outlook.FormRegion
Shadows WithEvents UserForm As Forms.UserForm
Shadows WithEvents Item As Outlook.AppointmentItem
Private WithEvents CtlRegion As MyAXCtrl
Public Sub New(ByVal region As Outlook.FormRegion, ByVal application
As Outlook.Application)
m_Application = application
Me.Item = region.Item
Me.FormRegion = region
Me.UserForm = CType(FormRegion.Form, Forms.UserForm)
InitializeControls()
End Sub
Private Sub InitializeControls()
CtlRegion =
DirectCast(UserForm.Controls.Item("MyAXCtrl1"),MyAXCtrl)
DisplayUserProperties 'assigns values to combos on
AXCtrl ,In AXCtrl while assigning values to
combo,AddModifyUserProperties()
'is avoided initially by a flag ,which is reset so after displaying
values to combo ,AddModifyUserProperties() gets invoked if combo is
changed
End Sub
Private Sub item_Write(ByRef cancel As Boolean) Handles Item.Write
'retrieves AXCtrl combo values & writes them to database.
End sub
Private Sub FormRegion_Close() Handles FormRegion.Close
If Not (m_Items Is Nothing) Then
m_Items = Nothing
End If
If Not CtlRegion Is Nothing Then CtlRegion = Nothing
If Not UserForm Is Nothing Then UserForm = Nothing
If Not FormRegion Is Nothing Then FormRegion = Nothing
If Not m_Application Is Nothing Then m_Application =
Nothing
RaiseClose()
End Sub
BaseFormRegionWrapper.vb
MustInherit Class BaseFormRegionWrapper
Implements IDisposable
Private Disposed As Boolean = False
Protected Item As Object
Protected WithEvents FormRegion As Outlook.FormRegion
Protected WithEvents UserForm As Forms.UserForm
Public Event Close As EventHandler
Protected Sub RaiseClose()
RaiseEvent Close(Me, EventArgs.Empty)
End Sub
Protected Overrides Sub Finalize()
Me.Dispose(False)
End Sub
Public Overloads Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
Protected Overloads Sub Dispose(ByVal disposeManagedResources As
Boolean)
If Not Me.Disposed Then
If disposeManagedResources Then
Item = Nothing
End If
If Not (FormRegion Is Nothing) Then
Marshal.ReleaseComObject(FormRegion)
FormRegion = Nothing
End If
If Not (UserForm Is Nothing) Then
Marshal.ReleaseComObject(UserForm)
UserForm = Nothing
End If
Disposed = True
End If
End Sub
Thanks
I've VSTO SE Addin for OL2007.I've adjoined form region to standard
Appointment form.I've placed AX Ctrl built using vb6 on that form
region.It prompts me for save even though I didn't make any change.The
AX Ctrl contains 2 combos.In combo change & click I'm calling
AddModifyUserProp which adds or modifies userprop value.B'coz of
addition/Modification of userprop values it may be prompting for
save,but once userprop gets added it should not prompt for save.but I
always get save prompt whenever I open existing item ,changes combo
contents & for save prompt I says no ,reopens same item & closes the
item without any change.Now though no change,it prompts me for
save.Below is the code-
AX Ctrl-
Public Sub AddModifyUserProp(ByVal PropName As String, ByVal PropValue
As String)
Set ObjAppointmentItem = ActiveInspector.CurrentItem
If Not ObjAppointmentItem Is Nothing Then
Dim userProperty As Outlook.userProperty
Set userProperty =
ObjAppointmentItem.UserProperties.Find(PropName, True)
If userProperty Is Nothing Then
Set userProperty =
ObjAppointmentItem.UserProperties.Add(PropName, olText, True)
End If
userProperty.Value = PropValue
Set ObjAppointmentItem = Nothing
End If
End Sub
ComposeAppoinmentFormRegionWrapper.vb -
Class ComposeAppoinmentFormRegionWrapper
Inherits BaseFormRegionWrapper
Private m_Application As Outlook.Application
Private WithEvents m_Items As Outlook.Items
Shadows WithEvents FormRegion As Outlook.FormRegion
Shadows WithEvents UserForm As Forms.UserForm
Shadows WithEvents Item As Outlook.AppointmentItem
Private WithEvents CtlRegion As MyAXCtrl
Public Sub New(ByVal region As Outlook.FormRegion, ByVal application
As Outlook.Application)
m_Application = application
Me.Item = region.Item
Me.FormRegion = region
Me.UserForm = CType(FormRegion.Form, Forms.UserForm)
InitializeControls()
End Sub
Private Sub InitializeControls()
CtlRegion =
DirectCast(UserForm.Controls.Item("MyAXCtrl1"),MyAXCtrl)
DisplayUserProperties 'assigns values to combos on
AXCtrl ,In AXCtrl while assigning values to
combo,AddModifyUserProperties()
'is avoided initially by a flag ,which is reset so after displaying
values to combo ,AddModifyUserProperties() gets invoked if combo is
changed
End Sub
Private Sub item_Write(ByRef cancel As Boolean) Handles Item.Write
'retrieves AXCtrl combo values & writes them to database.
End sub
Private Sub FormRegion_Close() Handles FormRegion.Close
If Not (m_Items Is Nothing) Then
m_Items = Nothing
End If
If Not CtlRegion Is Nothing Then CtlRegion = Nothing
If Not UserForm Is Nothing Then UserForm = Nothing
If Not FormRegion Is Nothing Then FormRegion = Nothing
If Not m_Application Is Nothing Then m_Application =
Nothing
RaiseClose()
End Sub
BaseFormRegionWrapper.vb
MustInherit Class BaseFormRegionWrapper
Implements IDisposable
Private Disposed As Boolean = False
Protected Item As Object
Protected WithEvents FormRegion As Outlook.FormRegion
Protected WithEvents UserForm As Forms.UserForm
Public Event Close As EventHandler
Protected Sub RaiseClose()
RaiseEvent Close(Me, EventArgs.Empty)
End Sub
Protected Overrides Sub Finalize()
Me.Dispose(False)
End Sub
Public Overloads Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
Protected Overloads Sub Dispose(ByVal disposeManagedResources As
Boolean)
If Not Me.Disposed Then
If disposeManagedResources Then
Item = Nothing
End If
If Not (FormRegion Is Nothing) Then
Marshal.ReleaseComObject(FormRegion)
FormRegion = Nothing
End If
If Not (UserForm Is Nothing) Then
Marshal.ReleaseComObject(UserForm)
UserForm = Nothing
End If
Disposed = True
End If
End Sub
Thanks