Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Save as .csv file


Reply
 
Thread Tools Display Modes
  #1  
Old 07-14-2012, 07:13 AM
bujaman bujaman is offline
Regular
 
Join Date: Mar 2009
Posts: 50
Default Save as .csv file


I am trying to write a macro to save each worksheet as a separate .csv file. The file name of the csv file needs to come from cell Z1 of each worksheet, but I am running into some problems, what I think should work, isn't (which is the case in so many aspects of my life!). Here is what I have, any ideas?

Code:
Sub SaveAsCSV()
     
    Dim FName As String
    Dim FPath As String
     
    FPath = "C:\Users\ben.griggs\Dropbox\BBP\Pricing Sheets\Converted Database Pricing Tables\"
    FName = ActiveSheet.Range("Z1").Text
  
    ActiveWorkbook.SaveAs Filename:=FPath & FName & ".csv", FileFormat:=xlCSVMSDOS

End Sub
Thanks in advance.
Reply With Quote
  #2  
Old 07-14-2012, 05:48 PM
brittonsm brittonsm is offline
Newcomer
 
Join Date: Jul 2012
Posts: 2
Default

Worked fine for me?

Maybe check to see if the file exist first or are you supressing the errors you receive (e.g. can only have one worksheet.)

If Len(Dir(strExcelPathTemp)) > 0 Then
Kill strExcelPathTemp
End If
Reply With Quote
Reply

Tags
csv, save as


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->