View Full Version : How can I use Excel 2003 Spreadsheet Component in Visual Basic 2005?


sfsepehr@gmail.com
05-21-2006, 10:05 PM
Hi all,

I'm new to Visual Basic 2005, but experienced in VB6. I use an Excel
spreadsheet in my program (that is OWC11). In VB6 I used to intract
with the spreadsheet like:

A(i , j) = frmSample.xlsSample.Cells(i , j).Value

& I could get the value in cell (i , j),. but now it doesn't work. Can
anybody help me regarding this mater?

Alvin Bruney
05-23-2006, 09:28 PM
The same syntax should work. Do you have data in those cells? can you set
data to those cells?

--

________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------

<sfsepehr@gmail.com> wrote in message
news:1148245548.086000.69430@j55g2000cwa.googlegroups.com...
> Hi all,
>
> I'm new to Visual Basic 2005, but experienced in VB6. I use an Excel
> spreadsheet in my program (that is OWC11). In VB6 I used to intract
> with the spreadsheet like:
>
> A(i , j) = frmSample.xlsSample.Cells(i , j).Value
>
> & I could get the value in cell (i , j),. but now it doesn't work. Can
> anybody help me regarding this mater?
>

sfsepehr@gmail.com
05-24-2006, 11:31 PM
Thanks Alvin. Actually I've found the solution by changing my code as:

Dim _Cell as OWC11.Range

_Cell=frmSample.xlsSample.Activesheet.Cells(i , j)
A(i , j)=_Cell.Value

& it fortunately works (using the "Activesheet" property). But now I've
got another probelm with multysheet spreadsheets. In VB6 I used to code
as

A(i, j)=frmSample.Sheet(2).Cells(i,j).Value

or

A(i,j)=frmSample.Sheet("Sheet2").Cells(i,j).Value

for example, but now in VB2005 even rewriting it as

Dim _sheet as OWC11.Sheets, _Cell as OWC11.Range

_Sheet=frmSample.Sheet("Sheet2" or 2)
_Cell=_Sheet.Cells(i,j)
A(i,j)=_Cell.Value

Doesn't work at all. I mean it yields to an error. I can delete current
sheet (Sheet1) or add another sheet, but I can't even rename the sheets
in VB2005 & interact with their cells values.

& please be sure Alvin thay of course I've got data in those cells.

Again Thanks for your reply.