Hi Alex,
You may try to run the code below to see if this is what you want?
namespace MyWordAddin3
{
using System;
using Microsoft.Office.Core;
using Extensibility;
using System.Runtime.InteropServices;
using Word = Microsoft.Office.Interop.Word;
[GuidAttribute("66064ECA-5EA3-4CF1-87FD-EE14ABE68983"),
ProgId("MyWordAddin3.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
public Connect()
{
}
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
wdApp = application as Word.Application;
}
public void OnDisconnection(Extensibility.ext_DisconnectMode
disconnectMode, ref System.Array custom)
{
}
public void OnAddInsUpdate(ref System.Array custom)
{
}
public void OnStartupComplete(ref System.Array custom)
{
cb = wdApp.CommandBars.Add("TestToolBar",oMissing,oMissing,oMissing);
cbb =
(CommandBarButton)cb.Controls.Add(MsoControlType.msoControlButton,oMissing,o
Missing,oMissing,oMissing);
cbb.Caption = "TestButton";
cbb.Click+=new _CommandBarButtonEvents_ClickEventHandler(cbb_Click);
}
public void OnBeginShutdown(ref System.Array custom)
{
}
object oMissing = System.Reflection.Missing.Value;
CommandBar cb;
CommandBarButton cbb;
private Word.Application wdApp=null;
private void cbb_Click(CommandBarButton Ctrl, ref bool CancelDefault)
{
System.Diagnostics.Debug.WriteLine("Clicked");
}
}
}
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.