VSTO unable to rename worksheet

J

Jorge Ribeiro

Hello

I'me trying to rename several worksheets with the folowing code.
When my worksheets are visible the renaming process throws an exception

Excel.worksheet sheet = ...

string oldName = sheet.Name;
Excel.XlSheetVisibility visibility = sheet.Visible;
// change name
sheet.Visible =
Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetVisible;
string newName = name + node.Attributes["suffix"].Value;
sheet.Name = newName;
sheet.Visible = visibility;

the newName string is well formed and my code only breaks at instruction
sheet.Name = newName; (error 0x800A03EC...)
it all goes well when my sheet is originally veryhidden.
when it is visible it sends an error

i'me running out of ideas.. can anyone help me

best regards

Jorge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top