Hi, I created another Import CSV object with the below code. See the "" 'added"" lines. In this case I'm passing in the ColumnDelimiter and ColumnArray text variables. My delimiter is ""~"" in this case, but you can pass in any delimiter you need (such as "","" etc.). The ColumnArray variable contains the column format numbers (ex. ""1,2,1"" where 1=general and 2=text), so column 1 would be general, column 2 would be text, column 3 general.
Dim dw, ds, dr, qt, ArrayText() As Object 'added ArrayText()
Dim i As Integer
Try
dw = GetWorkbook(Handle, Workbook)
ds = GetWorksheet(Handle, Workbook, Worksheet)
dr = ds.Range(Range)
qt = ds.QueryTables.Add(Connection:=""TEXT;"" & Path, Destination:=dr)
ArrayText = Split(ColumnArray,"","") 'added line
Dim ArrayNum(ArrayText.Length-1) as Integer 'added line
For i=0 to ArrayText.Length-1 'added line
ArrayNum(i) = ArrayText(i) * 1 'added line
Next 'added line
With qt
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = 1 'xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = startrow
.TextFileParseType = 1 'xlDelimited
.TextFileTextQualifier = Qualifier
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = ColumnDelimiter 'added ColumnDelimiter variable
.TextFileColumnDataTypes = ArrayNum 'added ArrayNum variable
.TextFileTrailingMinusNumbers = True
End With
qt.Refresh(False)
Success = True
Catch e As Exception
Success = False
Message = e.Message
Finally
dw = Nothing
ds = Nothing
dr = Nothing
qt = Nothing
End Try