You have built a managed code extension for Office Excel 2003. Your solution uses the Click
event of an MSForms CommandButton
control to remove rows from a List
object that is located on a worksheet. When you click the button to remove the List
row, the row is not removed, and you may receive a run-time error.
Microsoft has confirmed that this is a bug in Office Excel 2003.
To resolve this problem, make sure that CommandButton
does not have the focus when you delete the list row. Use one of the following methods:
- Set the TakeFocusOnClick property of CommandButton to false.
- Re-select the current worksheet selection to take the focus away from CommandButton.
To work around this problem, use one of the following methods:
- Set the TakeFocusOnClick property for the CommandButton control to false:
protected void ThisWorkbook_Open()
//Get a reference to the first worksheet.
ws = (Excel.Worksheet)(ThisWorkbook.Worksheets);
//Set up the Click event handler for CommandButton1.
cb = (MSForms.CommandButton)(this.FindControl("CommandButton1"));
cb.Click+= new MSForms.CommandButtonEvents_ClickEventHandler(cbClick);
cb.TakeFocusOnClick = false;
- Call the Select method for the current worksheet Selection to remove focus from the CommandButton:
private void cbClick()
Article ID: 823988 - Last Review: January 15, 2007 - Revision: 2.3
- Microsoft Office Excel 2003
- Microsoft Visual Studio Tools for the Microsoft Office System version 2003
|kbbug kbautomation kbnofix KB823988|