Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
SaveAs | Excel Programming | |||
SaveAs | Excel Worksheet Functions | |||
Using the SaveAs in VBA | Excel Programming | |||
Saveas | Excel Programming | |||
SaveAs,csv | Excel Programming |