local lcFileName lcFileName = upper(getfile("ExcelFiles:XLS","File Name:", "Open")) if type("lcFileName") <> "C" or right(lcFileName, 4) <> ".XLS" or empty(lcFileName) return endif local ox, oSheet ox = createobject("excel.application") loSheet = OpenXLFile(lcFileName) ProcessNewItems() loSheet = .null. loBook.Close() loBook = .null. ox.Quit() release ox return procedure OpenXLFile * lparameter tcFileName local loActiveSheet loBook = ox.Workbooks.Open(tcFileName) loActiveSheet = loBook.Sheets(1) return loActiveSheet procedure ProcessNewItems * local lnI, lnBlanks, lnValue local lcItem, lcDesc, lcUnits, lcPrice lnBlanks = 0 for lnI = 1 to 5000 lnValue = val(transform(loSheet.Cells[lnI, 1].Value)) if lnValue < 100000 && item_no must be 6 digits and at least '100000' lnBlanks = lnBlanks + 1 if lnBlanks > 10 && if >10 consecutive blank lines found, && probably no more to process exit endif loop endif lnBlanks = 0 with loSheet lcItem = alltrim(transform(.Cells[lnI, 1].Value)) lcDesc = alltrim(transform(.Cells[lnI, 2].Value, '@!')) lcUnits = alltrim(transform(.Cells[lnI, 3].Value, '@!')) lcPrice = val(transform(.Cells[lnI, 4].Value)) insert into Products ; ( Item_No, Descript, UnitPrice, Units, ItmPerUnit ) ; values ; ( lcItem, lcDesc, lcPrice, lcUnits, max(1, val(lcUnits)) ) endwith endfor return