Hi
Based on my research, the Undo/Redo button is a CommandBarComboBox type
which expose the Changed Event only.
Here is my test addin. But since the redo/undo button is kind of special
CommbandBarComboBox, it will have a button, but the button click event is
not exposed by Object Modal, so here we can add handler to the Changed
event which will fired when we click the little arrow beside the button and
then select one item, but it will not fire when we click the button
directly.
Based on my research, I did not find better workaround for this issue, if
you still have any concern, I suggest you contact MSPSS directly to see if
they have any better idea.
http://support.microsoft.com
Thanks for your understanding!
namespace MyWordAddin1
{
using System;
using Microsoft.Office.Core;
using Extensibility;
using System.Runtime.InteropServices;
using Word = Microsoft.Office.Interop.Word;
using System.Diagnostics;
[GuidAttribute("10F9EBA7-4332-4BA2-9C79-59AC13621BD6"),
ProgId("MyWordAddin1.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
public Connect()
{
}
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
Debug.WriteLine("OnConnection");
wdApp = application as Word.Application;
}
public void OnDisconnection(Extensibility.ext_DisconnectMode
disconnectMode, ref System.Array custom)
{
Debug.WriteLine("OnDisconnection");
}
public void OnAddInsUpdate(ref System.Array custom)
{
Debug.WriteLine("OnAddInsUpdate");
}
public void OnStartupComplete(ref System.Array custom)
{
Debug.WriteLine(wdApp.CommandBars[1].Name);
foreach(CommandBarControl cbc in wdApp.CommandBars[1].Controls)
{
if(cbc.Id == 128)
{
Debug.WriteLine("Found Control Undo");
cbcbUndo = cbc as CommandBarComboBox;
if (cbcbUndo!=null)
cbcbUndo.Change+=new
_CommandBarComboBoxEvents_ChangeEventHandler(cbcb_Change);
else
Debug.WriteLine("cbcbUndo is NULL");
}
if(cbc.Id == 129)
{
Debug.WriteLine("Found Control Redo");
cbcbRedo = cbc as CommandBarComboBox;
if (cbcbRedo!=null)
cbcbRedo.Change+=new
_CommandBarComboBoxEvents_ChangeEventHandler(cbcb_Change);
else
Debug.WriteLine("cbcbRedo is NULL");
}
}
}
public void OnBeginShutdown(ref System.Array custom)
{
Debug.WriteLine("OnBeginShutdown");
}
private Word.Application wdApp=null;
private CommandBarComboBox cbcbUndo=null;
private CommandBarComboBox cbcbRedo=null;
private void cbcb_Change(CommandBarComboBox Ctrl)
{
Debug.WriteLine("cbcb_Change");
}
}
}
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.