Martin Danner

I created an Excel Workbook project using Visual Studio and VSTO. This project uses the ListObject control bound to a DataTable to display and update data in SQL Server 2000 database.

When deployed to the user's workstation, this application has an annoying habit of disabling the Delete item on the Edit menu, preventing the user from deleting columns, rows or cells. Actually this is more than annoying - it's a show stopper.

Researching the problem online produced very little in the way of amswers. Are other people seeing this behavior

I did find a reference in this forum article:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=309265&SiteID=1

which suggests deleting Application Data\Microsoft\Excel\Excel11.xlb. This works, but its not acceptable to require the user to delete this file every time their Edit menu goes wonky.

Does anyone know how to create and deploy a VSTO Excel Workbook application in such a way that prevents this problem from occuring



Re: Visual Studio Tools for Office Excel Edit Delete Disabled

OmegaMan

If the user opens up a non VSTO document is Delete also disabled or only on the VSTO target document

Also is the control on the page or the action pane





Re: Visual Studio Tools for Office Excel Edit Delete Disabled

Nikhil Khandelwal - MSFT

Thank you for your feedback. You should not be seeing this behavior with solutions with ListObject in VSTO SE 2005 runtime. We have made some fixes in this region.

When ListObject is activated it disables the Edit->Delete option, because deleting columns in databound ListObjects is not allow. However, it re-enables the option once ListObject is not in active focus. You should be able to delete non-ListObject cells, rows, and columns in any case.

Let me know if this helps!

Thanks,
Nikhil






Re: Visual Studio Tools for Office Excel Edit Delete Disabled

Joe Cotugno

Hi Nikhil...

Unfortunately, one of my customers seems to be having this problem with the VSTO 2005 SE runtime installed.

While I have successfully been able to "fix" the problem by deleting the Application Data\Microsoft\Excel\Excel11.xlb file, I can not - as some other people have posted - use the code snippet you provided, as it will reset all toolbar customizations that my customer may have done (they are advanced Excel users and have many toolbar customizations). And forcing the customer to delete this file every time they use our VSTO solution is more than just an annoyance - it is a showstopper as they will not use our VSTO solution.

Do you have any other suggestions on how to fix this issue Even with VSTO 2005 SE runtime installed

Thanks,
Joe.






Re: Visual Studio Tools for Office Excel Edit Delete Disabled

Nikhil Khandelwal - MSFT

Hi Joe

What are you exactly seeing on the users' workstation ListObject disables the (Edit->Delete) menu entry only if your current selection in the spreadsheet is a databound ListObject. When you move the selection away to any other cell - the menu should get re-enabled.

Thanks,
Nikhil






Re: Visual Studio Tools for Office Excel Edit Delete Disabled

Joe Cotugno

Hi Nikhil...

To be clear, here is what happens:

1. The customer opens our Excel VSTO solution (which has databound ListObjects in it).
2. While the customer is within our Excel VSTO document, the Edit->Delete option is disabled when right-mouse clicking on a column header.
3. The client *closes* Excel - including our Excel VSTO document.
4. The client opens Excel - with *no* document - just Excel. A blank document appears.
5. The Edit->Delete option is *still* disabled when right-mouse clicking on a column header. :(

The customer has VSTO 2005 SE installed (I walked her through the installation myself).

Any ideas
Joe.






Re: Visual Studio Tools for Office Excel Edit Delete Disabled

Nikhil Khandelwal - MSFT

Hi Joe,

Thanks for the prompt response! One more question... so after you installed VSTO SE, did you reset the commandbars to ensure that edit-> delete was actually enabled
This is very strange and might be a bug. I have logged the issue that you are seeing and we will try to look into it. I will see if I can come up with a simpler workaround for now.

Thanks,
Nikhil






Re: Visual Studio Tools for Office Excel Edit Delete Disabled

Joe Cotugno

Hi Nikhil...

Yes, I asked my customer to reset the command bars (by deleting the above-mentioned file) so that the "Edit | Delete" command was enabled.

To be clear, the customer never had the VSTO 2005 runtime installed. We installed (together) VSTO 2005 SE runtime prior to deploying our VSTO-based solution, and the customer complained of the missing commands after opening another Excel workbook.

Thanks,
Joe.






Re: Visual Studio Tools for Office Excel Edit Delete Disabled

Martin Danner

Clearly the ListObject is not re-enabling the Delete Column feature in all cases. You can finnd a workaround to this problem in this post:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=455328&SiteID=1

Specifically:

private void Sheet1_Shutdown(object sender, System.EventArgs e)

{

for (int i = 1; i <= this.Application.CommandBars.Count; i++)

this.Application.CommandBars[ i ].Reset();

}

This forces the command bars to reset when you close the workbook. In this way the Delete Column feature is guaranteed to be re-enabled.





Re: Visual Studio Tools for Office Excel Edit Delete Disabled

Joe Cotugno

Hi Martin...

Thanks for the tip. However, as I explained in my previous post, I am not comfortable with this solution because it will reset ALL toolbar customizations in Excel. Our customers are advanced Excel users and are likely to have numerous toolbar customizations in place which we would not want to arbitrarily reset if we don't absolutely have to.

Thanks,
Joe.






Re: Visual Studio Tools for Office Excel Edit Delete Disabled

GennadyR

Hi,

For now you can do this.:

private void Sheet1_Shutdown(object sender, System.EventArgs e){

this.Application.CommandBars[ "Column" ].Reset();

}

In this way only the customization related to 'Column' will be affected and 'delete column'/'insert column' will function again. I just want to confirm that this bug happens on my computers with VSTO 2005 SE installed (Office Excel 2003(11.6355.6408), SP1). Nikhil said that this issue had been logged, hopefully it will get addressed ASAP as it is a big showstopper (it's not localized and affects all the excel files on a user's computer).

Regards,

Gennady.





Re: Visual Studio Tools for Office Excel Edit Delete Disabled

Nikhil Khandelwal - MSFT

Hi all,

My original workaround was very invasive for most heavy users of excel customisations. Therefore, I have come up with something which will just re-enable a subset of excel funcitonality disabled by ListObject. Please note that this may conflict with your user's settings or other customisations that work on the same menu entries.

This should surely re-enable your menus. It is also worth noting that this is required only if you are using databound listobjects.

/// <summary>
/// Re-enables the menu items disabled by databound listObjects.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Sheet1_Shutdown(object sender, System.EventArgs e)
{
int[] listOfIds = {860,// ID of the Form command button on the List command bar
7765,// ID of the "Resize List" command button on the List command bar
294, // ID of the Delete item on the Column context menu.
297, // ID of the Insert.Columns menu item on the Excel menu.
478, // ID of the Edit.Delete menu item on the Excel menu
7568, // ID of the Insert.Column menu item on the List toolbar
7569};// ID of the Delete.Column menu item on the List toolbar;

foreach (int id in listOfIds)
{
CommandBarControls menuControls = this.Application.CommandBars.FindControls(MsoControlType.msoControlButton, id, null, false);
foreach (CommandBarControl menuControl in menuControls)
{
menuControl.Enabled = true;
}
}
}

I hope this helps! In the meantime, we are having a look at this bug and seeing what can be done in future versions. I would like to thank all of you for your feedback!

Thanks,
Nikhil Khandelwal






Re: Visual Studio Tools for Office Excel Edit Delete Disabled

Hot Key

If a user is advanced enough to customize toolbars, they should be advanced enough to know <ctrl>+<->, which is more efficient than mouseclicks. Works nicely with <ctrl>+<spacebar> and <shift>+<spacebar>.