excel

R

RobcPettit

Hi Im using

Excel.Application excelApp = new Excel.ApplicationClass();

Excel.Sheets objSheets;
Excel._Worksheet objSheet;
Excel.Range range;

Excel.Workbook excelWorkbook
=excelApp.Workbooks.Open("C:\\Documents and Settings\\Robert\\Desktop\
\Baccarat two",
0, false, 5, "", "", false, Excel.XlPlatform.xlWindows,
"",
true, false, 0, true, false, false);
excelApp.Visible = true;
try
{

objSheets = excelApp.Worksheets;
objSheet = (Excel._Worksheet)objSheets.get_Item(1);

range = objSheet.get_Range("A50", Missing.Value);
range = range.get_Resize(5, 5);
//Create an array.
double[,] saRet = new double[5, 5];

//Fill the array.
for (long iRow = 0; iRow < 5; iRow++)
{
for (long iCol = 0; iCol < 5; iCol++)
{
//Put a counter in the cell.
saRet[iRow, iCol] = iRow * iCol;
}
}

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

to open an excel workbook and send some data to its. Works
perfect, this array is only a test to see if it works. What Id like to
do now, is when the workbooks open, leave it open and update the data
every xmins. The data side is no problem already done this. My problem
is sending the data to an already openend workbook. I keep gettitng
0x800a03ec errors. If I go back to reopening the workbook its ok. I
cant keep doing that though. Any advice appreciated.
Regards Robert
 
R

RobcPettit

I think ive craked it. Ive used excelApp =
(Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
to reference the rot table. I also found that I wasnt closing the file
correctly which left instance of excel in the procceses. If I get more
than one this code wont work.
Regards Robert
 

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