close

I'm trying to write a macro in VBA to do the following:

With ActiveSheet.QueryTables.Add(Connection:= _
quot;TEXT;C:\FLEXI01.PRNquot; _
, Destination:=Range(quot;A1quot;))
.Name = quot;FLEXI01quot;
.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 = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(22, 11, 11, 11, 11, 11, 11,
11, 11, 11)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

But I'd like to make it dynamic so it can go through a list of
locations/report names and import each one. The top few lines of the
finished result would look like this:
With ActiveSheet.QueryTables.Add(Connection:= curr_conn ,
Destination:=Range(quot;A1quot;))
.Name = curr_name

But I can't get the connection portion to work correctly - I've tried
building the text string like it's found above, but it didn't work.
Suggestions?

Thanks, Kim

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()