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?
Many thanks.
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