Sub readCsv()
Dim filePath As String
filePath = Sheet1.Cells(2, 3).Value
'MsgBox (filePath)
Sheet2.Rows().Clear
Dim TextLine
Dim rowLine As Integer
Dim lineArray() As String
changeRow = False
rowLine = 1
Dim startNewLineFlg As Boolean
Dim endNewLineFlg As Boolean
Dim lineArr() As String
Dim columnArr() As String
Dim columnNum As Integer
'MsgBox (TextGetByFile(filePath))
lineArr = Split(TextGetByFile(filePath), Chr(34) & vbCrLf)
For i = 1 To UBound(lineArr)
columnArr = Split(lineArr(i), ",")
For j = 1 To UBound(columnArr)
Sheet2.Cells(i, j).Value = Mid(columnArr(j - 1), 2, Len(columnArr(j - 1)) - 2)
Next
Next
End Sub
Sub makeCsv()
Dim filePath As String
filePath = Sheet1.Cells(4, 3).Value
cl = Sheet2.Range("AV" & Sheet2.UsedRange.Row).End(xlToLeft).Column
rw = Sheet2.Cells(65536, Sheet2.UsedRange.Column).End(xlUp).Row
Dim allStr As String
Dim lineStr As String
lineStr = ""
allStr = ""
For i = 1 To rw
For j = 1 To cl
If lineStr = "" Then
lineStr = """" & Sheet2.Cells(i, j).Value & """"
Else
lineStr = lineStr & ",""" & Sheet2.Cells(i, j).Value & """"
End If
Next
If allStr = "" Then
allStr = lineStr
Else
allStr = allStr & Chr(34) & vbCrLf & lineStr
End If
lineStr = ""
Next
MsgBox (allStr)
Open filePath For Output As #1
Print #1, allStr
Close #1
End Sub
Private Sub WriteOut(strPath As String, str As String)
If Not Dir(strPath, vbDirectory) = vbNullString Then
Kill (strPath)
End If
Dim ibufsize As Long
Dim irst
End Sub
Public Function TextGetByFile(ByVal pFileName As String) As String
Dim tOutText As String
Dim tBytes() As Byte
tBytes() = BytesGetByFile(pFileName)
tOutText = StrConv(tBytes(), vbUnicode)
TextGetByFile = tOutText
End Function
Public Sub TextPutToFile(ByVal pFileName As String, ByRef pText As String, Optional ByVal pFillFile As Boolean = False)
Dim tBytes() As Byte
tBytes() = StrConv(pText, vbFromUnicode)
BytesPutToFile pFileName, pBytes(), pFillFile
End Sub
Public Function BytesGetByFile(ByVal pFileName As String) As Byte()
Dim tOutBytes() As Byte
Dim tOutBytes_Length As Long
Dim tFileNumber As Integer
tFileNumber = FreeFile
Open pFileName For Binary As #tFileNumber
Dim tFileSize As Long
tFileSize = LOF(tFileNumber)
tOutBytes_Length = tFileSize - 1
ReDim tOutBytes(tOutBytes_Length)
Get tFileNumber, 1, tOutBytes()
Close #tFileNumber
BytesGetByFile = tOutBytes()
End Function
Public Sub BytesPutToFile(ByVal pFileName As String, ByRef pBytes() As Byte, Optional ByVal pFillFile As Boolean = False)
Dim tFileNumber As Integer
tFileNumber = FreeFile
If pFillFile Then
Open pFileName For Output As #tFileNumber
Close #tFileNumber
End If
tFileNumber = FreeFile
Open pFileName For Binary As #tFileNumber
Put tFileNumber, 1, pBytes()
Close #tFileNumber
End Sub