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

XLS-to-DBF Excel Automation with VFP: loWB.SaveAs errs 1

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
571
US
Colleagues,
I am trying to convert XLS file (Excel 97-2003 format) into a DBF (dBase4 format) for future use as DBF in VFP, using MS Excel 2007 ("Home" edition). Here's the code (off a test program):

Code:
lcXLS = "D:\SomeDir\SomeFile.XLS"
lcDBF = "D:\SomeDir\SomeFile.DBF"
loExcel = CREATEOBJECT("Excel.Application")
loWB = loExcel.WorkBooks.Open(lcXLS)
loWB.Sheets(1).Select
loWB.ActiveSheet.SaveAs(lcDBF, 11)
The last line is where this lil' program errs:

"OLE IDispatch exception code 0 from Micorsoft Office Excel:
Unable to get the SaveAs property of the WorkBook class.."

Searching the MS's MSDN produced only 3 hits, none of them of any help.

Could anybody here tell me where do I err?



Regards,

Ilya
 
If you look into your Excel 2007/2010 and attempt to manually do a Save As, you will find that the DBF4 option is no longer available - check it out yourself.
Note - this is not dependent on the format of the XLS file, but due to the version of the Excel application itself.

If that is the case, then your previous VFP Automation of this SaveAs operation will no longer work.

Instead you will need to change your previous automated SaveAs into the something else such as a CSV file and then do your conversion from CSV into DBF within your VFP itself.

Perhaps using something like
APPEND FROM NewCSV.CSV DELIMITED

Good Luck,
JRB-Bldr




 
Good point, JRB!
I didn't know this option was dropped off in/since Excel 2007!
Thank you, colleague!

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top