EXCEL.INTEROP working with Range and Cells
CGaralde
Member Posts: 19
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:
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:
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.
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.
0
Answers
-
No takers?

Anyway, I can write data to specific cells using:XlRange := XlWrkSht.Range('A1','A1'); XlRange.Value2 := 'XXXXXXX';
But it seems inefficient as I have to create XlRange each time I access a new cell. I was thinking of defining XlRange for multiple cells and just loop through it using CELLS but like I said, I cannot get the write syntax for it.
0 -
Hi, try to pass the cell address in one parameter:
XlWrkSht.Cells('C1').Value := 'ABCDE'Regards
xStepa0 -
Hi xStepa,
Thanks for taking the time but I have already tried that and I get the error that
Microsoft Dynamics NAV Development Environment
A maximum of 0 parameters must be used when calling the function. For example:
MyFunc( .. , .. , .. )
ROUND(MyVar)
ROUND(MyVar,0.05)
OK
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
