
Problems adding custom property pages
I'm trying to learn how to create a COM Add-in for Outlook
by following the example at:
http://www.*-*-*.com/
I think that I understand the directions, mostly.
However, after I build my COM-Addin, I don't see the "Wrox
Phone Number Changer" property page when I right-click on
a Contacts folder in the Folder List. Instead, I see
General, Home Page, Outlook Address Book, Activities,
Administration, Forms, Permissions, and Synchronization
tabs instead.
I had added the following Sub to my Outlook 2000 VBA code,
and restarted Outlook, I've even tried rebooting:
Private Sub moNS_OptionsPagesAdd(ByVal Pages As
PropertyPages, _
ByVal Folder As MAPIFolder)
On Error Resume Next
'For all contact folders load the custom Property Page.
If Folder.DefaultItemType = olContactItem Then
Pages.Add "PropertyPage.ctlPhoneChanger", "Wrox Phone
Number Changer"
End If
End Sub
Strangely, if I try to compile PhoneChanger.dll with
Outlook running I get
Permission denied: 'C:\mypath\PhoneChanger.dll'
So it looks like Outlook has the .dll loaded. As in the
example, I have my dsrPhoneChanger in a PhoneChanger.vbp
project and the basPhoneChanger and ctlPhoneChanger in a
PropertyPage.vbp project.
Both projects are in a PhoneChanger.vbg group. The
package and deployment wizard won't let me choose the
*.vbg, so I choose the PhoneChanger.vbp project and add
the PropertyPage.ocx to my project. I tried shutting down
Outlook, running the setup.exe in my Package folder, and
restarting Outlook, but I still don't see the property
page.
The code is basically cut and paste, all I had to do was
make sure to name my controls the same as in the example.
I commented out the following routines, that were added
automatically to my dsrPhoneChanger:
'Sub Hide()
'
' On Error Resume Next
'
' FormDisplayed = False
' mfrmAddIn.Hide
'
'End Sub
'Sub Show()
'
' On Error Resume Next
''
'' If mfrmAddIn Is Nothing Then
'' Set mfrmAddIn = New frmAddIn
'' End If
''
'' Set mfrmAddIn.VBInstance = VBInstance
'' Set mfrmAddIn.Connect = Me
'' FormDisplayed = True
'' mfrmAddIn.Show
''
'End Sub
''------------------------------------------------------
''this method adds the Add-In to VB
''------------------------------------------------------
'Private Sub AddinInstance_OnConnection(ByVal Application
As Object, ByVal ConnectMode As
AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As
Object, custom() As Variant)
' On Error GoTo error_handler
'
' 'save the vb instance
' Set VBInstance = Application
'
' 'this is a good place to set a breakpoint and
' 'test various addin objects, properties and methods
' Debug.Print VBInstance.FullName
'
' If ConnectMode = ext_cm_External Then
' 'Used by the wizard toolbar to start this wizard
' Me.Show
' Else
' Set mcbMenuCommandBar = AddToAddInCommandBar("My
AddIn")
' 'sink the event
' Set Me.MenuHandler =
VBInstance.Events.CommandBarEvents(mcbMenuCommandBar)
' End If
'
' If ConnectMode = ext_cm_AfterStartup Then
' If GetSetting
(App.Title, "Settings", "DisplayOnConnect", "0") = "1" Then
' 'set this to display the form on connect
' Me.Show
' End If
' End If
'
' Exit Sub
'
'error_handler:
'
' MsgBox Err.Description
'
'End Sub
''------------------------------------------------------
''this method removes the Add-In from VB
''------------------------------------------------------
'Private Sub AddinInstance_OnDisconnection(ByVal
RemoveMode As AddInDesignerObjects.ext_DisconnectMode,
custom() As Variant)
' On Error Resume Next
'
' 'delete the command bar entry
' mcbMenuCommandBar.Delete
'
' 'shut down the Add-In
' If FormDisplayed Then
' SaveSetting
App.Title, "Settings", "DisplayOnConnect", "1"
' FormDisplayed = False
' Else
' SaveSetting
App.Title, "Settings", "DisplayOnConnect", "0"
' End If
'
' Unload mfrmAddIn
' Set mfrmAddIn = Nothing
'
'End Sub
'
'Private Sub IDTExtensibility_OnStartupComplete(custom()
As Variant)
' If GetSetting
(App.Title, "Settings", "DisplayOnConnect", "0") = "1" Then
' 'set this to display the form on connect
' Me.Show
' End If
'End Sub
''this event fires when the menu is clicked in the IDE
'Private Sub MenuHandler_Click(ByVal CommandBarControl As
Object, handled As Boolean, CancelDefault As Boolean)
' Me.Show
'End Sub
It seems pretty straight-forward, any idea what I could
have done wrong?