Hi,
I have a routine that imports data into my excel worksheet. I would like to be prompted to locate the file but can't figure out how to incorporate a prompt within the following
Sub ImportData()
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\costs02.data", _
Destination:=Range("D1"))
.Name = "costs02"
.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 = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2, 9)
.TextFileFixedColumnWidths = Array(1, 6)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Thanks in advance
I have a routine that imports data into my excel worksheet. I would like to be prompted to locate the file but can't figure out how to incorporate a prompt within the following
Sub ImportData()
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\costs02.data", _
Destination:=Range("D1"))
.Name = "costs02"
.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 = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2, 9)
.TextFileFixedColumnWidths = Array(1, 6)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Thanks in advance