PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Program Addins button not firing when word is set as MailEditor.

Reply

button not firing when word is set as MailEditor.

 
Thread Tools Rate Thread
Old 11-06-2007, 03:43 PM   #1
Joe
Guest
 
Posts: n/a
Default button not firing when word is set as MailEditor.


Hi all

this is a much discussed problem, i m trying to use an outlook addin
which creates a button to the newInspector on clik of which some form
is opend.

it works fine for me when use all the other editors.. except word.

i ve seen Ken's post n other which suggest me to use Word Object
model. but i dont get how exactly should i do it.

here is my code in newInspector event :

Office.CommandBars oCommandBars;
Office.CommandBar oStandardBar;
myInspector = inspector;
oCommandBars = inspector.CommandBars;
oStandardBar = oCommandBars["Standard"];

Microsoft.Office.Interop.Word.Document ObjEditor;
try
{

if (inspector.IsWordMail() == false)
{
// code for other editors..
}
else
{
Redemption.SafeInspector safeInspector =
( Redemption.SafeInspector )
appObject.CreateObject( "Redemption.SafeInspector" );
safeInspector = ( Redemption.SafeInspector )
inspector;

ObjEditor =
(Microsoft.Office.Interop.Word.Document)safeInspector.WordEditor;
object omissing = System.Reflection.Missing.Value;
oStandardBar = ObjEditor.CommandBars["Standard"];
try
{
inspectorButton =
(Office.CommandBarButton)oStandardBar.Controls["Insert Invite"];
}
catch (Exception)
{

//inspectorButton =
(Office.CommandBarButton)oStandardBar.Controls["Insert Invite"];
inspectorButton =
(Office.CommandBarButton)oStandardBar.Controls.Add(1, omissing,
omissing, omissing, true);
inspectorButton.Caption = "Insert Link";
inspectorButton.Style =
Office.MsoButtonStyle.msoButtonIconAndCaption;
inspectorButton.OnAction = "!
<InsertLink.Connect>";
inspectorButton.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.inspectorButton_Click);
}
}
}
catch (Exception)
{

}

oCommandBars = null;
oStandardBar = null;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
but the Click event doesnt fire.. i ve seen some posts asking to use
Redemption. So i ve tried using that..

Please do give your opinions..

This is very critical to me as Outlook sets word as editor by
default.

thanks in advance.

Joe augustine.

  Reply With Quote
Old 13-06-2007, 03:19 PM   #2
Ken Slovak - [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: button not firing when word is set as MailEditor.

First of all, never use NewInspector to add UI. Use the first Activate
event. I just add my UI to Inspector.CommandBars, I never directly add to
the Word object. Where I do use the Word object is in Window_Activate to see
if it's an email window or a doc and to handle enabling/disabling my UI
appropriately.

--
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


"Joe" <jak0101@gmail.com> wrote in message
news:1181573008.876793.96150@g37g2000prf.googlegroups.com...
> Hi all
>
> this is a much discussed problem, i m trying to use an outlook addin
> which creates a button to the newInspector on clik of which some form
> is opend.
>
> it works fine for me when use all the other editors.. except word.
>
> i ve seen Ken's post n other which suggest me to use Word Object
> model. but i dont get how exactly should i do it.
>
> here is my code in newInspector event :
>
> Office.CommandBars oCommandBars;
> Office.CommandBar oStandardBar;
> myInspector = inspector;
> oCommandBars = inspector.CommandBars;
> oStandardBar = oCommandBars["Standard"];
>
> Microsoft.Office.Interop.Word.Document ObjEditor;
> try
> {
>
> if (inspector.IsWordMail() == false)
> {
> // code for other editors..
> }
> else
> {
> Redemption.SafeInspector safeInspector =
> ( Redemption.SafeInspector )
> appObject.CreateObject( "Redemption.SafeInspector" );
> safeInspector = ( Redemption.SafeInspector )
> inspector;
>
> ObjEditor =
> (Microsoft.Office.Interop.Word.Document)safeInspector.WordEditor;
> object omissing = System.Reflection.Missing.Value;
> oStandardBar = ObjEditor.CommandBars["Standard"];
> try
> {
> inspectorButton =
> (Office.CommandBarButton)oStandardBar.Controls["Insert Invite"];
> }
> catch (Exception)
> {
>
> //inspectorButton =
> (Office.CommandBarButton)oStandardBar.Controls["Insert Invite"];
> inspectorButton =
> (Office.CommandBarButton)oStandardBar.Controls.Add(1, omissing,
> omissing, omissing, true);
> inspectorButton.Caption = "Insert Link";
> inspectorButton.Style =
> Office.MsoButtonStyle.msoButtonIconAndCaption;
> inspectorButton.OnAction = "!
> <InsertLink.Connect>";
> inspectorButton.Click += new
> Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.inspectorButton_Click);
> }
> }
> }
> catch (Exception)
> {
>
> }
>
> oCommandBars = null;
> oStandardBar = null;
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> but the Click event doesnt fire.. i ve seen some posts asking to use
> Redemption. So i ve tried using that..
>
> Please do give your opinions..
>
> This is very critical to me as Outlook sets word as editor by
> default.
>
> thanks in advance.
>
> Joe augustine.
>


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off