excel vba - CSV Import into a spreadsheet fails on QueryTables method -
i need import info csv file. recorded macro below amended "querytablesadd" build concatnate file location contained in variable "fileloc". macro works until encounters .refresh backgroundquery := false method , fails @ point. if rem method, code runs through without failing. problem is, doesn't import data.
does have helpful hints?
with activesheet.querytables.add(connection:= _ "text;" & fileloc & chr(34), destination:=range("$a$1")) .name = "cdstats" .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 .textfilecommadelimiter = true .textfilecolumndatatypes = array(1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1) .textfiletrailingminusnumbers = true .refresh backgroundquery:=false end
for sake of answer:
you don't need quotes when passing variable, string variable
per @scott holtzman.
excel-vba excel-2010
No comments:
Post a Comment