Hi All,
I have written a macro to create a csv file. What I am doing is to write the data into the columns and then saving the file as "CSV". But now when I am trying to open the CSV using the export external data option in excel its displaying special characters as the data content.
But when I open the file by double clicking on it the data is rendered correctly.
Please help. Attaching the code below.
Sub splitLogExtract()
Dim temp_i As Integer
Dim temp_j As Integer
Dim temp_k As Integer
Dim newbook As Workbook
Dim newsheet As Worksheet
Dim firstline As Boolean
Dim temp_sheet As Integer
Dim fs As FileSystemObject
For temp_i = 1 To NumUniqueIssueType
Let temp_sheet = 0
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.fileExists("D:\SMS\" & UniqueIssueTypeList(temp_i) & ".csv") Then
Set newbook = Workbooks.Add
With newbook
.Title = ""
.Subject = ""
.SaveAs Filename:="D:\SMS\" & UniqueIssueTypeList(temp_i) & ".csv"
End With
newbook.Save
newbook.Close
Else
Kill ("D:\SMS\" & UniqueIssueTypeList(temp_i) & ".csv")
Set newbook = Workbooks.Add
With newbook
.Title = ""
.Subject = ""
.SaveAs Filename:="D:\SMS\" & UniqueIssueTypeList(temp_i) & ".csv"
End With
newbook.Save
newbook.Close
End If
Set newbook = Workbooks.Open("D:\SMS\" & UniqueIssueTypeList(temp_i) & ".csv")
'For temp_j = 1 To NumUniqueIssueType
For temp_k = 1 To NumDataLine
If issueTypeList(temp_k) = UniqueIssueTypeList(temp_i) Then
temp_sheet = temp_sheet + 1
Call WriteCell(temp_k, temp_sheet)
End If
Next 'temp_k NumDataLine
'Next 'temp_j NumUniqueIssueType
MsgBox ("temp_sheet: " & temp_sheet)
newbook.Save
newbook.Close
Next 'temp_i NumUniqueIssueType
End Sub
Sub WriteCell(ByVal NumLine As Integer, ByVal LineNum As Integer)
Dim temp_i As Integer
For temp_i = 1 To 50
Cells(LineNum, temp_i) = DataLine(temp_i, NumLine)
Next
End Sub
Bookmarks