Hi Ken, running with similar kind of problem.
I did as you mention, but could not get it working. Will appeciate
your help.
Private objCB As Office.CommandBar
Private WithEvents objCBButton As Office.CommandBarButton
Private Sub colInsp_NewInspector()
Dim mydoc As Word.Document
If Inspector.IsWordMail Then
Set mydoc = Inspector.WordEditor
Set objCB = mydoc.CommandBars("Standard")
Set objCBButton = CreateAddInCommandBarButton(strProgID, objCB,
"SMS", "SMS
Extension", "Send SMS Message", 0, True,
msoButtonIconAndCaption)
End Sub
Now CreateAddInCommandBarButton this bit of code I got it from the
"Com Addin for Outloom Template" form the
www.Slipstick.com website.
It works fine when i use plain Text but not when using word as emial
editor.
Anyway, i will put the code here.
In this function when using word as editor, i still get ctlBtnAddIn as
Nothing
after the following line of code, where as when using plain Text i
have that object
Set ctlBtnAddIn = objCommandBar.Controls.Add(Type:=msoControlButton,
Parameter:=strTag)
Public Function CreateAddInCommandBarButton _
(strProgID As String, objCommandBar As CommandBar, _
strCaption As String, strTag As String, strTip As String, _
intFaceID As Integer, blnBeginGroup As Boolean, intStyle As
Integer) _
As Office.CommandBarButton
Dim ctlBtnAddIn As CommandBarButton
Dim objPicture As stdole.IPictureDisp
Dim objMask As stdole.IPictureDisp
Dim str As String
str = App.Path + "\MESSAGEmanager.bmp"
On Error Resume Next
' Test to determine if button exists on command bar.
Set ctlBtnAddIn = objCommandBar.FindControl(Tag:=strTag)
If ctlBtnAddIn Is Nothing Then
' Add new button.
Set ctlBtnAddIn =
objCommandBar.Controls.Add(Type:=msoControlButton,
Parameter:=strTag)
Set objPicture = LoadPicture(str)
Set objMask = LoadPicture(str)
With ctlBtnAddIn
.Caption = strCaption
.Tag = strTag
'for image comment these three lines
If intStyle <> msoButtonIconAndCaption Then
.FaceId = intFaceID
End If
.Style = intStyle
.Picture = objPicture
.Mask = objMask
.ToolTipText = strTip
.BeginGroup = blnBeginGroup
' Set the OnAction property with ProgID of Add-In
.OnAction = "<!" & strProgID _
& ">"
End With
End If
' Return reference to new commandbar button.
Set CreateAddInCommandBarButton = ctlBtnAddIn
End Function