ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VSTO unable to rename worksheet (https://www.excelbanter.com/excel-programming/424327-vsto-unable-rename-worksheet.html)

Jorge Ribeiro

VSTO unable to rename worksheet
 
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.x lSheetVisible;
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

Jorge Ribeiro

VSTO unable to rename worksheet
 
SOLVED:

I first have to unprotect workbook structure...

thanx anyway

"Jorge Ribeiro" wrote:

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.x lSheetVisible;
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



All times are GMT +1. The time now is 05:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com