excel - Error parsing CSV to XLS with VBA script -


this function designed open csv file, , import data specific sheet on excel workbook.

but think there kind of problem can't resolve in cases delimiters.

this function:

sub loopallexcelfilesinfolder_invenotry()    dim strfilename string   dim wsmstr  worksheet:   set wsmstr = thisworkbook.sheets("all_actius")    if msgbox("erase sheet before start importing?", vbyesno, "delete?") _ = vbyes wsmstr.usedrange.clear    strfilename = application.getopenfilename _                 (filefilter:="csv file (*.csv), *.csv", _                 title:="select csv file: ")   worksheets("all_machines").activate  activesheet.querytables.add(connection:= _     "text;" & strfilename, _     destination:=range("a1"))     .fieldnames = true     .rownumbers = false     .filladjacentformulas = false     .preserveformatting = true     .refreshonfileopen = false     .refreshstyle = xlinsertdeletecells     .savepassword = false     .savedata = true     .adjustcolumnwidth = true     .refreshperiod = 0     .textfilepromptonrefresh = false     .textfileplatform = 1252     .textfilestartrow = 1     .textfileparsetype = xldelimited     .textfiletextqualifier = xltextqualifierdoublequote     .textfileconsecutivedelimiter = false     .textfiletabdelimiter = true     .textfilesemicolondelimiter = true     .textfilecommadelimiter = false     .textfilespacedelimiter = false     .textfilecolumndatatypes = array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)     .textfiletrailingminusnumbers = true     .refresh backgroundquery:=false  end  end sub 

this part of source code (csv file), containing line not beeing "translted" expected:

enter image description here

here can see how line translated excel. 12x5" string should'nt there. first column should contain ip addresses.

enter image description here

i'm pretty sure it's delimiter character issue, can't find solution.

the workbooks.open command worked me issue.

dim wb workbook  strfilename = "yourfilename.csv"  set wb = workbooks.open(filename:=strfilename, local:=true) 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

delphi - Disable and change color of node in Treeview -

elasticsearch python client - work with many nodes - how to work with sniffer -