immediately resposne to changes in a custom property page?

  • Thread starter Thread starter tomer
  • Start date Start date
T

tomer

Hi,

I am trying to handle changes in my add in preferences.
In order to to that,i added a property page to OPTION property pages
collection,
The property page is an OCX which Raise OnChange() event

In the add-in i am trying to do something like this:

public WithEvents m_PropPage as PropPage.Prop

Private Sub objOutlook_OptionsPagesAdd(ByVal Pages As Outlook.PropertyPages)
Set m_PropPage = CreateObject("PropPage.Prop") '***********Here i get Type
Mismatch*************
end sub

Is there any other way to immediately resposne to changes in the custom
property page

thanks in advance
 
Expose a public class module in your addin to the OCX. You can do that
by exposing it in a public property of your designer class. In the
On_Connection code make sure to set AddInInst.Object = Me

It would go something like this:

class declaration, public class, exposes public method(s) that are
used to alert your addin that the OCX has changed something.

In designer:

Public Property Get PPClass() As clsPublicClass
'clsPublicClass is the public class, instantiated as
'moPublicClass
On Error Resume Next

If moPublicClass Is Nothing Then
Set moPublicClass = New clsPublicClass
End If
Set PPClass = moPublicClass
End Property

when you instantiate the property page you can set any properties you
want available to your OCX.

In the OCX UserControl:

Private m_oAddinBase As Object
Private m_oAddinSecond As Object

In the OCX InitProperties event handler:

Dim objOL As Outlook.Application

On Error Resume Next

Set objSite = Parent
m_blnDirty = False

'Set IsLoading to True so that setting controls will not dirty form
m_blnLoading = True

Set objOL = CreateObject("Outlook.Application")

Set m_oAddinBase = objOL.COMAddIns("MyAddin.Connect").Object
If Not (m_oAddinBase Is Nothing) Then
Set m_oAddinSecond = m_oAddinBase.PPClass
'now you can get any public properties of the class and call any
'of its methods when you want.
End If

If you have a method in the class that refreshes whatever was changed
in the OCX the call to that method from the OCX is all you need.
 
Back
Top