책에서 VBE 기초 학습 후 마침내 나는 csv 파일을 여는 매크로를 만들려고 노력했다. csvname으로 저장하고 모두 완료 될 때까지 다시 실행하십시오.csv 가져 오기
입력 csv 파일 다음 줄에 문제가 있습니다. 그것은 오류 번호 13을 제공합니다, 나는 그것을 해결하는 방법에 대한 단서가 전혀 없습니다. 나는 현재 거기에 변수를 넣을 수 없다고 생각합니까? 내가 맞습니까? 어떤 해결책이 있습니까?
이
Sub CSVnaarxlsx()
'On Error Resume Next
'declareer variabelen
Dim strpath As String
Dim fmn As Integer
Dim lmn As Integer
Dim csvname As String
'active workbook pathway
strpath = Application.ActiveWorkbook.Path
'ask user for first and last number
fmn = InputBox("first mouse number")
lmn = InputBox("last mouse number")
'einde sub if inputbox is empty
'If fmn = "" Then
'MsgBox "No first mouse number"
'Exit Sub
'End If
'If lmn = "" Then
'MsgBox "No Last mouse number"
'Exit Sub
'End If
'assign variables
'loop al de files
For fmn = fmn To (lmn + 1)
csvname = "m" & fmn
'input of csv file
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;strpath & "/" & csvname" & ".csv""" _
, Destination:=Range("sheet1!$A$1"))
.Name = csvname
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 _
, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1)
.TextFileDecimalSeparator = "."
.TextFileThousandsSeparator = ","
.TextFileTrailingMinusNumbers = True
End With
Call CsvToXlsx(ByVal csvname, strpath)
Next fmn
End Sub
Sub CsvToXlsx(ByVal csvname, strpath)
ChDir (strpath & "/verwerkt")
csvname = csvname & .xlsx
ActiveWorkbook.SaveAs Filename:=csvname, FileFormat:=51
End Sub
답변에 만족하는 경우 언제든지 수락하십시오. 다음은 스크린 샷 형태의 초고속 설명입니다. http://i.stack.imgur.com/uqJeW.png –