#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default SaveAs csv

Hi,

I have to save one specific sheet (or a copy of this sheet) as a scv
file but at the same time I want to keep the original workbook a xls
file.
Is it possible to do this with a macro ???

thanks in advance
Gert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default SaveAs csv

Gert wrote:

Hi,

I have to save one specific sheet (or a copy of this sheet) as a scv
file but at the same time I want to keep the original workbook a xls
file.
Is it possible to do this with a macro ???

thanks in advance
Gert


Sub saveascsv()

Dim SaveName
SaveName = "C:\mycsvfile.csv" 'you can refer to a range.text if you want to
make this dynamic

Worksheets("Sheet1").Copy
Workbooks(Workbooks.Count).Activate
Workbooks(Workbooks.Count).SaveAs SaveName, xlCSV
Workbooks(Workbooks.Count).Close SaveChanges:=False

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default SaveAs csv

hi,
yes it is. but you left out some critical info. Is the cvs file going to
always have the same name? here are 2 possible ways. change and don't change.

Sub mac1SaveRange()
Sheets("Sheet1").activate ' change this to your sheet name
Cells.Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Application.CutCopyMode = False
'use this code if the name DOES NOT change
'ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\My Documents\XCEL\deleteme.csv", _
FileFormat:=xlCSV, CreateBackup:=False
'change deleteme to your file name.
'use this code if the name DOES change
'Application.Dialogs(xlDialogSaveAs).Show
end sub

Post back if you have problems. I will be going to work soon and probably
wont be back to news groups until tonight. But I'll check to see.

Regards
FSt1
"Gert" wrote:

Hi,

I have to save one specific sheet (or a copy of this sheet) as a scv
file but at the same time I want to keep the original workbook a xls
file.
Is it possible to do this with a macro ???

thanks in advance
Gert


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default SaveAs csv

I'd use the same kind of code as Damian, but use the Activeworkbook:

Sub saveascsv2()

Dim SaveName as String
SaveName = "C:\mycsvfile.csv" 'you can refer to a range.text if you want to
'make this dynamic

Worksheets("Sheet1").Copy
with activeworkbook
.SaveAs SaveName, xlCSV
.Close SaveChanges:=False
end with

End Sub

Gert wrote:

Hi,

I have to save one specific sheet (or a copy of this sheet) as a scv
file but at the same time I want to keep the original workbook a xls
file.
Is it possible to do this with a macro ???

thanks in advance
Gert


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default SaveAs csv

Damien, not Damian.

(Sorry Damien)

Gert wrote:

Hi,

I have to save one specific sheet (or a copy of this sheet) as a scv
file but at the same time I want to keep the original workbook a xls
file.
Is it possible to do this with a macro ???

thanks in advance
Gert


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SaveAs Daviv Excel Programming 2 March 4th 07 01:34 AM
SaveAs Stan Halls Excel Worksheet Functions 5 November 28th 06 07:51 PM
Using the SaveAs in VBA caldog Excel Programming 2 October 5th 05 01:05 AM
Saveas Dale Levesque Excel Programming 6 May 5th 04 04:06 PM
SaveAs,csv popo pop Excel Programming 2 October 31st 03 06:08 AM


All times are GMT +1. The time now is 03:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"