ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem in exporting to csv (https://www.excelbanter.com/excel-programming/399596-problem-exporting-csv.html)

glenn[_3_]

Problem in exporting to csv
 

hi all


I wanted to export a workbook (it has only one worksheet) to a csv file,
so I used this code:


ActiveWorkbook.SaveAs Filename:= "c:\aFile.csv", FileFormat:=xlCSV
,CreateBackup:=False

It works fine, but after I run it i find myself working in Excel within
the aFile.csv file instead of the initial aFile.xls.

How can I export to the csv while remaining inside the xls after the export?

Thanks!


Mike H.

Problem in exporting to csv
 
After exporting,

ActiveWorkbook.SaveAs FileName:=X, _
FileFormat:=xlCSV, CreateBackup:=False
ActiveWindow.Close , savechanges:=False

Then you would be where you were before you added this workbook. But if you
must go someplace else, you could explicitly return somewhere else:

Windows("FirstFile.xls").Activate




All times are GMT +1. The time now is 01:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com