Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Saving and closing Excel file properly
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01396469
Message ID:
01396473
Vues:
61
>Hi,
>
>Here's an annoying problem I have. I want to transform a .XLS file into a .CSV file. I found that it's not possible to have semi-colom delimitation so I go with TAB delimiter.
>
>
>oExcel = CREATEOBJECT("Excel.Application")
>WITH  oExcel.Workbooks.Open(cFichier)
>
>	***Nom du nouveau CSV
>	cNewFichier = JUSTPATH(cFichier) + JUSTFNAME(cFichier) + ".csv"
>	IF FILE(cNewFichier)
>		ERASE cNewFichier
>	ENDIF 
>
>	WAIT WINDOW cNewFichier
>	.SaveAs(cNewFichier)
>	.close()
>ENDWITH 
>
>oExcel.Quit()
>oExcel.visible = .T.
>oExcel = NULL
>RELEASE oExcel
>...
>APPEND FROM cNewFichier DELIMITED WITH TAB
>...
>
>
>
>The file saves properly with the saveas() method, but right on the next line ( ".close()") it asks me if I want to save the file which doesn't seem to make sense.
>
>The second problem, definitly related to that is that my APPEND FROM says that the file does not exist (even though it does). If I replace the cNewFichier with the "?", I open the CSV file manually and it does work.
>
>Thank you!

I would try to set oExcel.DisplayAlerts=.F. to see if SaveAs prompt persists. In regard to the second problem, it seems that Excel creates files too 'slow' so it is not available yet when APPEND FROM issued. Try to insert one of these (or both) lines right before APPEND FROM:
Doevents
Wait '' Window Timeout 1
Edward Pikman
Independent Consultant
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform