I'm writing a VB.NET application that generates an Excel file.
My intention here is to write a particular formula that uses CONCATENATE
in a cell.
Now, the following line of code fires the above exception:
0) tSheet.Cells(tIncRow + ItemIndex * PixelIndex + PixelIndex, 2).Formula =
"=CONCATENATE(" & Pixels(PixelIndex) & ";Batches!J3)"
The following row does NOT raise the exception. (It's simply the row above without the =
at the beginning. The fact that it doesn't raise the exception means that the indexes are used properly; I'll get rid of them in the following passages to ease the notation). Also, if I manually put in Excel an =
in front of the very same formula, then the formula gives a correct result (it correctly grabs Batches!J3
)
1) tSheet.Cells(tIncRow + ItemIndex * PixelIndex + PixelIndex, 2).Formula =
"CONCATENATE(" & Pixels(PixelIndex) & ";Batches!J3)"
The following line also runs without problem:
2) tSheet.Cells(indexes).Formula = "=CONCATENATE(" & Pixels(PixelIndex) & ")"
This line works as well:
3) tSheet.Cells(indexes).Formula = "=CONCATENATE(Batches!J3)"
It seems that only the combination of 2) and 3) raises the exception.
I'm using Visual Studio 2012, Excel 2007, and I'm including Microsoft Excel 12.0 Object Library
Thanks for any help!