Question about property panes in Outlook

V

Victor Heijke

I made an Outlook addin with Visual Basic.Net (2003) and VSTO.
I cannot get the Outlook Options panes to work. Here is what I did:
Created a UserControl : added a textbox to it and the line
Implements Outlook.PropertyPage (directly under the Inherits)

On the TextChanged event of the textbox has the following code
Dim myPropertyPageSite = Parent
gblDirty = True
myPropertyPageSite.OnStatusChange()
and nothing more.

The pane is added in Connect.vb (I used a withevents on the
Outlook.applicatopn objOLApp) with:

Private Sub objOLApp_OptionsPagesAdd(ByVal PropPages As
Microsoft.Office.Interop.Outlook.PropertyPages) Handles
objOLApp.OptionsPagesAdd
Try
Dim ctrOptionsPage As New ctrOptions
PropPages.Add(ctrOptionsPage, "More options")
Catch ex As SystemException
Debug.WriteLine("OptionsPagesAdd Exception: {0}", ex.Message)
End Try
End Sub


The pane is added, but no title is availble (it says untitled)
Second problem is that the parent object in the User Control is nothing and
therefore the myPropertyPageSite is unavailble.

Who can help me.
Victor Heijke
 
K

Ken Slovak - [MVP - Outlook]

Don't use an object there. Call the property page using a ProgID for the
user control (OCX).
 
V

Victor Heijke

I found it to...

for the Apply: On http://www.codeproject.com/dotnet/PropertyPages.asp I
found a C# solution. I translated it to

'Dim mytype As Type = GetType(System.Object)

Dim MyAssem As String =
System.Text.RegularExpressions.Regex.Replace(mytype.Assembly.CodeBase,
"mscorlib.dll", "System.Windows.Forms.dll")

MyAssem = System.Text.RegularExpressions.Regex.Replace(MyAssem, "file:///",
"")
MyAssem = System.Reflection.AssemblyName.GetAssemblyName(MyAssem).FullName
Dim unmanaged As Type =
Type.GetType(System.Reflection.Assembly.CreateQualifiedName(MyAssem,
"System.Windows.Forms.UnsafeNativeMethods"))

Dim oleObj As Type = unmanaged.GetNestedType("IOleObject")
Dim mi As System.Reflection.MethodInfo = oleObj.GetMethod("GetClientSite")
Dim myppSite As Object = mi.Invoke(Me, Nothing)
fPropertySite = CType(myppSite, Outlook.PropertyPageSite)

but it does not work
The myppSite object stays nothing.
 
K

Ken Slovak - [MVP - Outlook]

As I said, don't use an object there, use a ProgID reference. Using an
object, while supported, has never worked correctly in the vast majority of
cases.
 
V

Victor Heijke

I thought you were talking for the title.
Can you be more specific about your solution?

Thanks
Victor
 
K

Ken Slovak - [MVP - Outlook]

This is using VB 6 code:

Private Sub objOutlook_OptionsPagesAdd(ByVal Pages As Outlook.PropertyPages)
Dim strPPTitle As String

On Error Resume Next

UpdateActivityTimer

strPPTitle = "My Property Page Tab Title"
Pages.Add "OCX_Name.UserControl1", strPPTitle
End Sub

where "OCX_Name" is the name of the project used to create the property page
OCX and "UserControl1" is the name of the UserControl object used.
 
V

Victor Heijke

Thanks, but that part is/was already working. The problem is in the Apply
button for the PropertyPageSite. I cannot get the propertypagesite of a class
that implements a outlook.propertypage. The parent is empty.

Victor
 
K

Ken Slovak - [MVP - Outlook]

Ah. The code I use for that looks like this:

Module level in UserControl1 code:

Implements Outlook.PropertyPage
Private objSite As Outlook.PropertyPageSite

'always use InitProperties for these initializations
Private Sub UserControl_InitProperties()
Dim objOL As Outlook.Application

On Error Resume Next

Set objSite = Parent

Set objOL = objSite.Application 'gets a trusted Outlook application object

' more initializations
End Sub
 
V

Victor Heijke

I'l have more and less the same, but the parent is nothing

Public Class ctrOptions
Inherits System.Windows.Forms.UserControl
Implements Outlook.PropertyPage

Private fPropertySite As Outlook.PropertyPageSite

Public Sub New()
MyBase.New()
InitPhase = True
InitializeComponent()

fPropertySite = Parent 'here is Parent, Me.Parent etc. all nothing
End Sub
 
K

Ken Slovak - [MVP - Outlook]

Obviously the property page isn't being correctly instantiated but I can't
tell you why. I avoid using .NET code for Outlook addins due to the many
problems and drag on program speed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top