ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving files (https://www.excelbanter.com/excel-programming/307262-saving-files.html)

Cindy

Saving files
 
I have a workbook that has a macro that does a save as
saves a csv file. The problem is that until you close
the file and re-open it, it still has formuals, multiple
worksheets, etc in it. For my purposes, I need the file
to be a true csv file.

Is there a way to do a file save as and close that file
with out closing the current excel file. OR save the
current file as an excel file then save as again as a csv
file then open the excel file and close the csv file.

To complicate it more the file is opened originally as a
read only and I would have to come up with some type of
name for the save.

Any help will be greatly appreciated.

Cindy.

Dave Peterson[_3_]

Saving files
 
Are you sure you're opening the .csv file the second time?

Try it with a nice unique name--just to verify.

I'm not sure what your macro does, but if you copy the worksheet to a new
workbook, then save that, it might work better for you:

Option Explicit
Sub testme01()
Dim wks As Worksheet
Set wks = Worksheets("sheet1")
wks.Copy 'to a new workbook
With ActiveSheet.Parent
.SaveAs Filename:="whateveryousaveitas.CSV", FileFormat:=xlCSV
.Close savechanges:=False
End With
Workbooks.Open Filename:="whateveryousaveitas.CSV"
End Sub



Cindy wrote:

I have a workbook that has a macro that does a save as
saves a csv file. The problem is that until you close
the file and re-open it, it still has formuals, multiple
worksheets, etc in it. For my purposes, I need the file
to be a true csv file.

Is there a way to do a file save as and close that file
with out closing the current excel file. OR save the
current file as an excel file then save as again as a csv
file then open the excel file and close the csv file.

To complicate it more the file is opened originally as a
read only and I would have to come up with some type of
name for the save.

Any help will be greatly appreciated.

Cindy.


--

Dave Peterson


Cindy

Saving files
 
Dave, Thanks for the help.
-----Original Message-----
Are you sure you're opening the .csv file the second

time?

Try it with a nice unique name--just to verify.

I'm not sure what your macro does, but if you copy the

worksheet to a new
workbook, then save that, it might work better for you:

Option Explicit
Sub testme01()
Dim wks As Worksheet
Set wks = Worksheets("sheet1")
wks.Copy 'to a new workbook
With ActiveSheet.Parent
.SaveAs Filename:="whateveryousaveitas.CSV",

FileFormat:=xlCSV
.Close savechanges:=False
End With
Workbooks.Open Filename:="whateveryousaveitas.CSV"
End Sub



Cindy wrote:

I have a workbook that has a macro that does a save as
saves a csv file. The problem is that until you close
the file and re-open it, it still has formuals,

multiple
worksheets, etc in it. For my purposes, I need the

file
to be a true csv file.

Is there a way to do a file save as and close that file
with out closing the current excel file. OR save the
current file as an excel file then save as again as a

csv
file then open the excel file and close the csv file.

To complicate it more the file is opened originally as

a
read only and I would have to come up with some type of
name for the save.

Any help will be greatly appreciated.

Cindy.


--

Dave Peterson

.



All times are GMT +1. The time now is 10:53 PM.

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