Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QT.Add Syntax Problem

Status
Not open for further replies.

abitslow

Technical User
Apr 25, 2003
44
I have a piece of code which I grabbed from a recorded Macro and I want to substitute the Connection destination with the result of a GetOpenFilenam so people can chose files whenever they use the spreadsheet. I can't get it to work. What am I doing wrong?

Code:
Sheets("Grid_ML").Activate
GridDAT = Application.GetOpenFilename

With ActiveSheet.QueryTables.Add _
(Connection:="TEXT;GridDAT", Destination:=Range("A2"))
        .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
        .TextFileConsecutiveDelimiter = True
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = True
        .TextFileColumnDataTypes = Array(1, 1, 1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
End With
Many thanks.
 




Code:
    (Connection:="TEXT;[red][b]" & GridDAT[/b][/red], Destination:=Sheet2.Range("A2"))

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Brilliant - worked a treat. Thanks Skip
 


:)

Skip,
[sub]
[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FOURTH[/red] on the [red]FIFTH[/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top