Aug 24, 2003 #1 apascual Programmer Joined Jun 17, 2003 Messages 11 Location PH help! how will i write a csv file format using visual basic? data will be coming form sql tables. can anyone send me a source code? tnx in advance.
help! how will i write a csv file format using visual basic? data will be coming form sql tables. can anyone send me a source code? tnx in advance.
Aug 25, 2003 #2 bryanbayfield Technical User Joined Aug 10, 2001 Messages 345 Location EU Either use the filesystemobject (common to all ms office object models) or use open filename for [append|output] as #filenumber. Try digging around in teh VBA help files. Upvote 0 Downvote
Either use the filesystemobject (common to all ms office object models) or use open filename for [append|output] as #filenumber. Try digging around in teh VBA help files.
Aug 25, 2003 #3 ETID Programmer Joined Jul 6, 2001 Messages 1,867 Location US Access or Excel? Upvote 0 Downvote
Aug 25, 2003 Thread starter #4 apascual Programmer Joined Jun 17, 2003 Messages 11 Location PH excel file Upvote 0 Downvote
Aug 26, 2003 #5 terzaghi Programmer Joined Aug 25, 2003 Messages 49 Location IT Hi, try this Sub CreateAfile() Dim str As String Set fs = CreateObject("Scripting.FileSystemObject" Set a = fs.CreateTextFile("c:\testfile.txt", True) str = Worksheets("Sheet1".Cells(6, 3).Value & ", " & Worksheets("Sheet1".Cells(6, 4).Value a.WriteLine (str) a.Close End Sub I've taken this from the help of VBA. hope this will help A Upvote 0 Downvote
Hi, try this Sub CreateAfile() Dim str As String Set fs = CreateObject("Scripting.FileSystemObject" Set a = fs.CreateTextFile("c:\testfile.txt", True) str = Worksheets("Sheet1".Cells(6, 3).Value & ", " & Worksheets("Sheet1".Cells(6, 4).Value a.WriteLine (str) a.Close End Sub I've taken this from the help of VBA. hope this will help A
Aug 26, 2003 #6 ETID Programmer Joined Jul 6, 2001 Messages 1,867 Location US saves the active sheet....you can splice variables into the path and file name to make it more dynamic. ActiveWorkbook.SaveAs Filename:= _ "C:\my_path\file_name.csv", FileFormat:=xlCSV, _ CreateBackup:=False Upvote 0 Downvote
saves the active sheet....you can splice variables into the path and file name to make it more dynamic. ActiveWorkbook.SaveAs Filename:= _ "C:\my_path\file_name.csv", FileFormat:=xlCSV, _ CreateBackup:=False