Using C# in .NET 3.5 with Visual Studio 2008, I am trying to set focus (or activate) a specific worksheet in an open workbook:
Here are some properties:
public Excel.Application xlApp {get;set;}
public Excel.Workbook xlWorkBook { get; set; }
public Excel.Worksheet xlWorkSheet { get; set; }
public Excel.Range range { get; set; }
And here is how I am trying to select a specific worksheet:
(xlWorkSheet)Application.ActiveWorkbook.Sheets[FormControls.WorksheetFocus]).Select(Type.Missing);
And I have also tried this way:
((Excel.Worksheet)this.Application.ActiveWorkbook.Sheets[1]).Select();
What am I doing wrong? How do I select a specific worksheet in a workbook using C#?