Quantcast
Channel: NAV Three Tier — mibuso.com
Viewing all articles
Browse latest Browse all 10032

EXCEL.INTEROP working with Range and Cells

$
0
0
Hi,

For grizzled veterans, this may be a very trivial question but I am having problems working on Ranges and Cells on Excel.Interop.

Basically, I have the following code:

FileName := 'C:\Book1.xlsx';

XlApp := XlApp.ApplicationClass;

XlWrkBk := XlApp.Workbooks.Open(FileName,0,TRUE,5,'','',TRUE,2,'\t',FALSE,FALSE,0,TRUE,1,0);

XlWrkSht := XlWrkBk.Sheets.Item(1);

XlRange := XlWrkSht.Range('A1','A10');


How do I work with the cells in the defined XlRange? I searched for it a lot but I could not seem to find the correct syntax. I tried the following:
XlWrkSht.Cells(3,1).Value2 := 'ABCDE';
XlRange.Cells(1,1).Value2 := 'XXXXX';
XlRange.Cells[1,1].Value2 := 'XXXXX';

And I get a "parameter 0" error or a "too many dimensions" error. I understand the errors but for the life of me, I do not know how else to manipulate the cells within a range. Any help is greatly appreciated. :smile:

Viewing all articles
Browse latest Browse all 10032

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>