Problem Naming Worksheet

M

mikebabb

I have a C# program accessing the Excel interop. No matter what I do,
I can't get the name of the active worksheet to change from "Sheet1".
Here's basically the code.

MSExcel.Application xlApp = null;
MSExcel._Workbook wkb = null;
MSExcel._Worksheet wks = null;
string sheetName = "Opportunites";

xlApp = new MSExcel.Application();
wkb = xlApp.Workbooks.Add(MSExcel.XlWBATemplate.xlWBATWorksheet);
wks = (MSExcel._Worksheet) wkb.ActiveSheet;
wks.Name = sheetName;

Is there anything else I need to do?
 
M

mikebabb

I should have added that when I look at the worksheet name in the
debugger, it does appear as "Opportunities". However, when Excel is
made visible, the sheet name is still named "Sheet1".
 

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