Raoshan,
I think you need to reference the ActiveSheet as follows:
.ActiveSheet.cells(nRow, 1).Value = custlist.name
.ActiveSheet.cells(nRow, 2).Value = custlist.address
Or some other worksheet. Other worksheets if present will be accessible through
.Sheets("mySheet").. where mySheet is the name of the target worksheet. HTH
>Hi All,
>
>I'm getting this message while opening an Excel file and inserting contents into it through COM
>
>The Error is like this :
>
>"OLE IDespatch exception code 0 from Microsoft Excel ?.."
>
>one more strange thing is that this error comes only when I run the exe and not in the interactive mode from within the VFP
>
>I've written the code like this:
>
>loExcel = GETOBJECT(, "Excel.Application")
>
>WITH loExcel
> .WorkBooks.Open("C:\MSTLIST.XLS", ,.T.) && Open the file read only
>
> nRow = 4
> SELECT custlist
> SCAN
> .cells(nRow, 1).Value = custlist.name
> .cells(nRow, 2).Value = custlist.address
> ENDSCAN
>
> .Visible = .T.
>ENDWITH
>
>I'm using VFP 3.0, MS-Excel 2000/XP and Windows 98
>
>Please help me to solve the problem
>
>Thanks
>
>Raoshan