I am writing a Add-In for excel where i have to store workbookspecific settings in the excel file. I tryed to create a new worksheet, and hide it.
settingsSheet.Visible = XlSheetVisibility.xlSheetHidden;
Now my application was always writing to my open worksheet, not the hidden settingsworksheet. If i remove the part which hides the worksheet, it works fine.
Is there a way to write to hidden excel worksheets? Or is there a better way to store settings?
edit: aditional code
Worksheet newWorksheet;
string newWorksheetname = "SettingsSheet";
foreach (Worksheet sheet in ActiveWorkbook.Sheets)
{
if (sheet.Name == newWorksheetname)
{
newWorksheet = sheet;
}
}
if (newWorksheet == null)
{
newWorksheet = (Worksheet)Globals.ThisAddIn.Application.Worksheets.Add();
newWorksheet.Name = newWorksheetname;
}
newWorksheet.Visible = XlSheetVisibility.xlSheetHidden;
newWorksheet.Cells[1,1].Value="settingsValue";