I have a code here that import data in an excel file to csv. It can import other laguages like japanese, chinese characters. It can also import numbers. My problem is, it cannot import the cell that contains only the number zero "0". Did i miss anything? Thanks
Code:
Dim SrcRg As Range
Dim CurrRow As Range
Dim CurrCell As Range
Dim CurrTextStr As String
Dim FName As Variant
FName = Application
If FName <> False Then
Set SrcRg = ActiveSheet.UsedRange
End If
Set fst = CreateObject("ADODB.Stream")
fst.Type = 2
fst.Charset = "utf-8"
fst.Open
For Each CurrRow In SrcRg.Rows
CurrTextStr = ""
For Each CurrCell In CurrRow.Cells
If CurrCell.Value <> Empty Then
cellvalue = Replace(CurrCell.Value, Chr(34), Chr(34) & Chr(34))
CurrTextStr = CurrTextStr & """" & cellvalue & """" '& ""
Else
CurrTextStr = CurrTextStr '& ""
End If
Next
fst.writetext CurrTextStr, 1
If (fst.Position < fst.EOS) Then
fst.SetEOS = fst.Position
End If
Next
fst.SaveToFile "C:\Users\file.csv", 2
MsgBox "Extract completed "
End If
End Sub