Monday, March 12, 2012

VB Script which create a CSV file

Sub Create_CSV_File()
Dim FileName, CSVPath, CSVFile As String

CSVPath = "C:\CSV_Folder\"
CSVFile = "CSV_File_Name.csv"

FileName = CSVPath + CSVFile

Open FileName For Output As #1
Print #1, "records 01" & "," & "records 02" & "
For i = 2 To 10
Print #1, Worksheets("Sheet1").Cells(i, 1).Value & "," & Worksheets("Sheet1").Cells(i, 1).Value & "
Next i
Close #1

MsgBox ("Successfully cerated ")

End Sub

No comments: