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

save excel to csv problem

Status
Not open for further replies.

borsker

Programmer
Jul 24, 2002
147
0
0
US
i am using this code to save an excel document to a csv.
Code:
loExcel = Createobject([Excel.application])
With loExcel
   STORE 'mcInFile = "'+GETFILE('XLS')+'"' TO excelfile
   &excelfile
   loExcel.workbooks.Open(mcInFile)
   loSheet = .activesheet
   With loSheet
      .Range([A1]).Select
   Endwith
ENDWITH
loExcel.Workbooks(1).SaveAs('MyCSV.csv',xlCSV)
loExcel.workbooks.CLOSE
loExcel.Quit
Release loExcel
the problem is the xlCSV part.
Code:
loExcel.Workbooks(1).SaveAs('MyCSV.csv',xlCSV)
vfp errors and says "Variable 'XLCSV' is not found. any ideas?
 
I've got the save thing down now, but how do I get rid of the pesky save problem that keeps coming up when i run it.
I am erasing all instances of the file then saving, but it still wants to give me the save warning before i close the excel list. Here is the code.
Code:
***************************************************************************************
************************************************************  excel sheet
***************************************************************************************
loExcel = Createobject([Excel.application])
With loExcel
    mcInFile = "c:\temp_data\MyExcel.xls"
    loExcel.workbooks.Open(mcInFile)
    loExcel.visible=.F.
    loSheet = .activesheet
    With loSheet
    	.Range([A1]).Select
      Endwith
ENDWITH
erase Mylist.csv
mcOutDBF = "c:\temp_data\Mylist.csv"
loSheet.SAVEas (mcOutDBF,6)

* --- Close the Worksheet ---
loExcel.workbooks.CLOSE
loExcel.Quit
Release loExcel
Close All
*****************************
*****************************

The save question keeps coming up right before the workbook closes. And it will ask me to save the file i just saved, just like in excel. Any ideas?
 
Sorry about that, I found it.

Code:
loExcel.DisplayAlerts = .f.

i knew it was somthing simple, i just could not find it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top