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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

APPEND FROM ... TYPE XLS

Status
Not open for further replies.

ron108

Programmer
Jun 19, 2002
14
US
I have a VFP 6.0 routine that would append an Excel file to a dbf file using the following command:

APPEND FROM filename TYPE XLS

For over a year this worked for all of the files that I received as Excel.

Then I began to get Windows Level Error Messages and the entire program would shut down on one of two computers. One of the computers continued to run the code without a problem but then it also started doing the same thing.

I was able to get it running again by change the DBF file structure, but then that solution stopped working.

I have tried the XL5 AND XL8 options also.

Right now I go to Excel and save the files as DBF and go from there.

Any Ideas??
 
it sounds like that the spread sheet does not have the same data structure?

I convert the excel into a table first then compare the structure

obj = CREATEOBJECT('excel.application')
obj.APPLICATION.workbooks.OPEN(cfile)
obj.APPLICATION.workbooks(1).SAVEAS(cprogdir+'junk.dbf',8)
obj.APPLICATION.workbooks(1).saved = .T.
obj.APPLICATION.QUIT

now I can compare the fields to insure it matches. Attitude is Everything
 
You may be having problems if the spreadsheet was created in Excel 2000 (version 9) or 2002 (alias XP or version 10) and it uses any of the newer formating or functionality.

Danceman's code should work, unless you have a version of Excel before 2000 and the SS is later.

Rick

 
So how would I determine the version of EXCEL. I receive files from about 10 different sources that come as EXCEL files. Is there some way of finding the version # before I commit it to a VFP program?
 
id you use the code above to open it as an excel file, then convert it to a free dbf

SAVEAS(cprogdir+'junk.dbf',8)
cprogdir is stored the path to where you want to store the file. the 8 means to create free old style table. Foxpro can read in the old table for you to compare the fields. Attitude is Everything
 
The only sure way to know, is to always have the newest version of Excel on the "converter" machine, and then save each as a type VFP can handle directly, or use Danceman's code.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top