I am working on MS Excel 2013 generating report where all the worksheets in workbook should have freeze pane at column 6 and row 1. I have searched on Google but could not find any solution as for freezing the pane, workbook has to be active. I have tried a lot of things but no success. I will really appreciate if someone can help me.

```
Excel.Application excel = new Excel.Application();
Excel.Workbook workbook = excel.Workbooks.Open("filelocation");

foreach (Excel.Worksheet ws in workbook.Worksheets)
{
    ws.Application.ActiveWindow.SplitColumn = 6;
    ws.Application.ActiveWindow.SplitRow = 1;
    ws.Application.ActiveWindow.FreezePanes = true;
}

excel.Visible = true;

```