General information
Category:
Coding, syntax & commands
This might do it for you (you would have to modify your own code to refer to the active sheet:
LOCAL myActivesheet,oWb
lcXLSFile = 'c:\book1.xls'
lcRange = "b2:b500"
oExcel = CREATEOBJECT("excel.application")
oWb= oExcel.Workbooks.OPEN(lcXLSFile)
myActiveSheet=oExcel.Application.WorkBooks(1).workSheets("sheet2")
myActiveSheet.activate
oExcel.visible = .t.
>I am using the following code to access Excel File from Visual Foxpro prog which I received from UT only. Thanks for that. Since my excel file is having multiple worksheets how can I point to a particular work sheet?
>--------------------------------------------------------------------------
>lcXLSFile = 'c:\path\YourXls.xls'
>lcRange = "b2:b500"
>oExcel = createobject("excel.application")
>With oExcel
> .Workbooks.open(lcXLSFile)
> With .ActiveWorkbook.ActiveSheet.range(lcRange)
> For ix = 1 to .Rows.count
> For jx = 1 to .Columns.count
> ? .Cells(ix,jx).Value
> Endfor
> Endfor
> Endwith
> .quit
>Endwith
>-----------------------------------------------------------------------------
>
>Thanks in Advance.
>
>Regards
>
>Ashish Patel
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only