For quite some time now, I have struggled with importing 2007 excel files.
With a lot of help from Richard Quilhot, I've ended up with the following.
I needed this especially with 1 client in particular where they had 18
users and 3 different versions of Excel.

Some of the beginners here (like me) may like to see a snippet of my code

mx=SYS(5)+CURDIR()+"RMLIMP.XLS"
Try
   Append From (mx) Type Xl5                    &&Sheet (msheet)
Catch
   =Messagebox('Sorry, the system has a problem with that spreadsheet.
The system will now try and convert it',0,'')
   WAIT WINDOW NOWAIT "Converting the spreadsheet, patience please "
   DO killprg WITH 'EXCEL'        && kill excel if it happens to be open
   oExcel = CreateObject("Excel.Application")
   oWorkbook = oExcel.Workbooks.Open("&mx")
   *nFileFormat = oWorkbook.FileFormat  && Find out what file type source is
   *?nFileFormat  && display results

   IF FILE("convertedmx.xls")
      DELETE file convertedmx.xls
   endif

   newfile=SYS(5)+CURDIR()+"convertedmx"
   oWorkbook.SaveAs('&newfile',39)
   oExcel.quit()
   DO killprg WITH 'EXCEL'
   WAIT WINDOW NOWAIT "Converted, now trying again "
   TRY
      Append From (newfile) Type Xl5                   &&Sheet (msheet)
   CATCH TO oException
      IF !oException.errorno=39   && this suits me in THIS instance
         thiswentok=.F.
         =Messagebox("Sorry, the system has a problem with that
spreadsheet. Even converting didn't help"+CHR(13)+;
         "Error number "+STR(oException.errorno),0,'')
      ELSE
         =Messagebox("The spreadsheet was converted and imported but
encountered NUMERIC OVERFLOW because of errors in the
spreadsheet",0,'Oh dear')

      endif
   endtry
Endtry

--
Regards
Sytze de Boer
Kiss Systems
Hamilton, NZ
Ph: 64-7-8391670, Mob:64 21 937611
URL: www.kiss.co.nz

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to