Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXCEL problem

Status
Not open for further replies.

EC1

Programmer
Jul 22, 2002
25
BE
Hi,

how can i loop into an existing excel file?
Something like scan-endscan.

thank you
 
EC1

It depends what you need to do, but here is an example, the displays all the values from row 1 (from columns 1 through 64)
Code:
LOCAL oExcel as excel.application
LOCAL oWorkbook as Excel.workbook
oExcel = CREATEOBJECT("excel.application")
oWorkBook = oExcel.Workbooks.Open("c:\cezar3.xls")
oWorkbook.Sheets(1).Select
WITH oWorkbook.Sheets(1)
   FOR i = 1 TO 64
    ? .cells(i,1).text
   endfor
ENDWITH


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks Mike,

this is very helpfull.


but the number of rows in the excel file are not allways the same. How can i know how many rows there are, without opening the file of course.

thanks
 
Sorry Mike,

the number of rows are the same, the number of columns are not

Thanks
 
Will the first returned empty() value be the last column?
I sometimes look for the first null returned to detirmine when to stop looking if I know all columnes contain values until I hit the end. Also used for last row. I sometimes will set my loop to go way across and way down skipping cells with empty() values like all the way across to BZ or more and through rows 50000 this will make the loop much slower but will catch all the cells. really depends on how the excell is made-up.

Steve Bowman
steve.bowman@ultraex.com

 
Thanks Steve.

There are no empty cells, so, the first empty cell is the last.
Thanks for your suggestion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top