Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Export worksheet to .csv
I am trying to export multiple worksheets to .csv. This is what I have
so far: For v = 1 To 7 Sheets(v).Select ActiveWorkbook.SaveAs Filename:= _ "C:\" & .Name & ".csv", FileFormat:=xlCSV, _ CreateBackup:=False Next v When I run the code, I get an error "Method Save As of object '_WorkBook' failed". Any ideas on how to fix this? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Export worksheet to .csv
Omar
I think you just more information about where the .name is supposed to come from. Try: For v = 1 To 7 Sheets(v).Select ActiveWorkbook.SaveAs Filename:= _ "C:\" & activeworkbook.Name & ".csv", FileFormat:=xlCSV, _ CreateBackup:=False Next v Good luck. Ken Norfolk, Va On Sep 27, 2:44 pm, Omar wrote: I am trying to export multiple worksheets to .csv. This is what I have so far: For v = 1 To 7 Sheets(v).Select ActiveWorkbook.SaveAs Filename:= _ "C:\" & .Name & ".csv", FileFormat:=xlCSV, _ CreateBackup:=False Next v When I run the code, I get an error "Method Save As of object '_WorkBook' failed". Any ideas on how to fix this? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Export worksheet to .csv
Try this
Sub test() Dim a As Integer Dim wb As Workbook Application.ScreenUpdating = False For a = 1 To ThisWorkbook.Worksheets.Count ThisWorkbook.Sheets(a).Copy Set wb = ActiveWorkbook wb.SaveAs "C:\" & wb.Sheets(1).Name & ".csv", FileFormat:=xlCSV wb.Close False Set wb = Nothing Next a Application.ScreenUpdating = True End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Omar" wrote in message oups.com... I am trying to export multiple worksheets to .csv. This is what I have so far: For v = 1 To 7 Sheets(v).Select ActiveWorkbook.SaveAs Filename:= _ "C:\" & .Name & ".csv", FileFormat:=xlCSV, _ CreateBackup:=False Next v When I run the code, I get an error "Method Save As of object '_WorkBook' failed". Any ideas on how to fix this? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Export worksheet to .csv
Thanks Ron, that worked.
Ken, the only problem with that code is that it overwrites the same file. I forgot about that. On Sep 27, 3:23 pm, "Ron de Bruin" wrote: Try this Sub test() Dim a As Integer Dim wb As Workbook Application.ScreenUpdating = False For a = 1 To ThisWorkbook.Worksheets.Count ThisWorkbook.Sheets(a).Copy Set wb = ActiveWorkbook wb.SaveAs "C:\" & wb.Sheets(1).Name & ".csv", FileFormat:=xlCSV wb.Close False Set wb = Nothing Next a Application.ScreenUpdating = True End Sub -- Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm "Omar" wrote in ooglegroups.com... I am trying to export multiple worksheets to .csv. This is what I have so far: For v = 1 To 7 Sheets(v).Select ActiveWorkbook.SaveAs Filename:= _ "C:\" & .Name & ".csv", FileFormat:=xlCSV, _ CreateBackup:=False Next v When I run the code, I get an error "Method Save As of object '_WorkBook' failed". Any ideas on how to fix this? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Export Excel WorkSheet | Excel Discussion (Misc queries) | |||
Export worksheet only | Excel Programming | |||
Needed: worksheet export help | Excel Discussion (Misc queries) | |||
export favorites into worksheet | Excel Programming | |||
Export each worksheet to csv | Excel Programming |