Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / April 2004

Tip: Looking for answers? Try searching our database.

custom button does not appear if MS Word is Editor

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shiv Kotagal - 12 Mar 2004 05:58 GMT
Hi,
I have a COM AddIn which creates a custom button on
inspectors holding MailItems. I used the wrapper class as
shown in the ItemCB example and it works well if MS Word
is not the Editor. If MS Word is the Editor the View-
>Toolbars-> list seems to be altogether different and the
custom button is nowhere to be seen.

Please help ! deadline approaching :-( Any help will be
really appreciated.

Thanks,
Shiv Kotagal
Ken Slovak - [MVP - Outlook] - 12 Mar 2004 17:11 GMT
Buttons added to a WordMail container must be added using code in Word.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Hi,
> I have a COM AddIn which creates a custom button on
[quoted text clipped - 9 lines]
> Thanks,
> Shiv Kotagal
Shiv Kotagal - 15 Mar 2004 18:04 GMT
Thanks Ken,
I tried doing this, but am not able to proceed. here is what i did.

1. created a designer module to connect to Word on
   startup and create a global say, WordApplication which is a
Word.Application object.

2. in the newInpector event in outlook, if the editor is word, i did the
following.

Sub newINspector()
   Dim mydoc as Word.document
   If inspector.editortype = olEditorWord
       Set mydoc = WordApplication.ActiveDocument   'this fails
       Set myCommandBar = mydoc.commandbars
       '
       '
       code to add a commandbarbutton
   End If

End sub

with the above code when I open a rich text document with Word as the
editor, it tells me that mydoc cannot be initialized since no document is
open.
can you please give me a clue to proceed or direct me to some code which i
can refer to. Thanks !!

regards,
Shiv
> Buttons added to a WordMail container must be added using code in Word.
>
[quoted text clipped - 11 lines]
> > Thanks,
> > Shiv Kotagal
Ken Slovak - [MVP - Outlook] - 16 Mar 2004 15:11 GMT
The way I get the current document in the Word editor is different, see if
this helps:

Dim mydoc As Word.Document

If Inspector.IsWordMail Then
   Set mydoc = Inspector.WordEditor
   'whatever

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Thanks Ken,
> I tried doing this, but am not able to proceed. here is what i did.
[quoted text clipped - 26 lines]
> regards,
> Shiv
Mita Garg - 07 Apr 2004 06:02 GMT
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

> The way I get the current document in the Word editor is different, see if
> this helps:
[quoted text clipped - 35 lines]
> > regards,
> > Shiv
Ken Slovak - [MVP - Outlook] - 07 Apr 2004 15:10 GMT
Buttons in WordMail must be created using Word code and not Outlook code.
You'd have to put the code in an autorun macro in Word's normal.dot template
and in that code check to see if the document was an email so the button
wasn't there for normal documents.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Hi Ken, running with similar kind of problem.
>
> I did as you mention, but could not get it working. Will appeciate
> your help.
<snip
Mita Garg - 08 Apr 2004 01:25 GMT
Hi Ken,

Thanks for your reply. Would you mind posting a sample, because I have
no idea how to do that. and If a create the button in a macro, how
will my Addin respond to the button click event. How am i going to
distribute( or deploy) that macro on the client machine.

> Buttons in WordMail must be created using Word code and not Outlook code.
> You'd have to put the code in an autorun macro in Word's normal.dot template
[quoted text clipped - 6 lines]
> > your help.
> <snip
Ken Slovak - [MVP - Outlook] - 08 Apr 2004 21:27 GMT
Your Word code would have to handle the click events and somehow pass
anything that's needed to the Outlook addin. Some people have created dual
addins that have designers for both Outlook and Word and do things that way.

I don't do that type of coding and really never have bothered with buttons
on WordMail Inspectors so I can't give you more detail or any sample code.
You can try Googling to see if there are any posts that show sample code for
it or even maybe try a Word newsgroup.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Hi Ken,
>
> Thanks for your reply. Would you mind posting a sample, because I have
> no idea how to do that. and If a create the button in a macro, how
> will my Addin respond to the button click event. How am i going to
> distribute( or deploy) that macro on the client machine.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.