sameerasnd
New Member
Hi All,
I need to import CSV file to the Excel work sheet while assigning data types for data columns in CSV file. For that I created Excel macro code like bellow and it was succeeded in Excel.
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\sandaruwans\Documents\RPA_Finance\DP Automation\a.txt", _
Destination:=Range("$A$1"))
.Name = "a"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "|"
.TextFileColumnDataTypes = Array(2, 2, 2, 2, 1, 2, 1, 2, 4)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
so I try to changed duplicated Import CSv Action in Excel VBO with the bold item above but It gives following error when check the code.
Compiler error at line 32: 'Array' is a type and cannot be used as an expression.
Please help me on this regards.
Thanks
sameera.
I need to import CSV file to the Excel work sheet while assigning data types for data columns in CSV file. For that I created Excel macro code like bellow and it was succeeded in Excel.
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\sandaruwans\Documents\RPA_Finance\DP Automation\a.txt", _
Destination:=Range("$A$1"))
.Name = "a"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "|"
.TextFileColumnDataTypes = Array(2, 2, 2, 2, 1, 2, 1, 2, 4)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
so I try to changed duplicated Import CSv Action in Excel VBO with the bold item above but It gives following error when check the code.
Compiler error at line 32: 'Array' is a type and cannot be used as an expression.
Please help me on this regards.
Thanks
sameera.