Question : Get active workbook name C#

I am trying to send data to an worksheet in an already open Excel workbook, but I cannot get my code to work properly. Please help!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
public void writeArray(String[,] saRet, long rows, int col)
    {  
        Excel.Application objApp;
        Excel._Workbook objBook;
        Excel._Worksheet objSheet;
        Excel.Range range;

            objApp = new Excel.Application();
            objBook = (Excel.Workbook)objApp.ActiveWorkbook;
            objSheet = (Excel.Worksheet)objBook.Worksheets["Not COD"];
            
            

            //Get the range where the starting cell has the address
            //m_sStartingCell and its dimensions are m_iNumRows x m_iNumCols.
            range = objSheet.get_Range("A1", Missing.Value);
            range = range.get_Resize(rows, col);

            //Set the range value to the array.
            range.set_Value(Missing.Value, saRet);

            //Return control of Excel to the user.
            objApp.Visible = true;
            objApp.UserControl = true;
        }

} // Test

Answer : Get active workbook name C#

I dont see anything wrong in your code though. check this link
http://support.microsoft.com/kb/316126
Random Solutions  
 
programming4us programming4us