Using Inspector to add to Insert menu in Outlook - doesn't work if using Word as the editor

S

Scott M. Lyon

I'm working on a VB6 addin for Outlook (home-grown) that currently has an
additional menu item on the Insert menu when drafting a new e-mail.

In a nutshell, each time that the new option is selected, something (in this
case, a web link) is added to the e-mail body.


When I try it with Outlook set to use the default editor, it works
perfectly.


However, when I try it with Outlook set to use Word (both from Office
XP/2002), it allows me to add one link, but then it never hits the _Click
event for that option again (even with break points there, running in debug
mode - it will hit the first time, but never again).


Here's code (from various places in the application) for what I'm trying to
do:


Public WithEvents myItems As Inspectors
Dim colCB As Office.CommandBars
Dim InsertMenu As CommandBarPopup
Dim RefPopUp As CommandBarPopup
Const DROPDOWN_MENU As Integer = 10
Const MENU_BUTTON = 1
Dim WithEvents cbbLink As CommandBarButton



Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)

Set myItems = objApplication.Inspectors

End Sub

Private Sub myItems_NewInspector(ByVal Inspector As Outlook.Inspector)

Set myItem = Inspector
If myItem.CurrentItem.Class = olMail Then
Set Item = myItem.CurrentItem
Else
Exit Sub
End If

Set colCB = myItem.CommandBars

On Error Resume Next
Set InsertMenu = colCB.FindControl(id:="30005")

Set RefPopUp = InsertMenu.Controls.Item("Insert Ref...")

Set RefPopUp = InsertMenu.Controls.Add(DROPDOWN_MENU)
RefPopUp.Caption = "Siena Ref..."
RefPopUp.BeginGroup = True
RefPopUp.Tag = "Siena Ref"

Set cbbLink = RefPopUp.Controls.Add(MENU_BUTTON)
cbbLink.Caption = "Link"

cbbLink.OnAction = "!<Navigator.Connect>"

End Sub



Then there's a subroutine defined as: Private Sub cbbLink_Click(ByVal Ctrl
As Office.CommandBarButton, CancelDefault As Boolean) with all of the logic.
I've been putting a breakpoint on the first line of that _Click event, and
the first time I use the Insert Ref -> Link it hits the breakpoint and works
perfectly (using Word as the editor). Second time, it never hits the
break-point again when I select the Insert Ref -> Link



Any ideas?


Thanks!
 

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