flyfisher15
11-11-2011, 09:18 AM
I'm trying to have a .txt file imported to excel. The file to import would be selected based on user input.
Here's what I have. Whenever I run this i get an object error.
Sub FDR_Data_get()
Dim filedate As String
Sheets("FDR Data").Select
filedate = InputBox("Enter the FDR file load date in mm-dd-yyyy format", "Date Entry")
With Sheets("FDR Data").QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\####\Desktop\Macro File\Inbox\FDR PDF Report\*" & filedate & "*" _
, Destination:=Range("A1"))
.Name = "*" & filedate & "*"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Any help would be greatly appreciated!
Here's what I have. Whenever I run this i get an object error.
Sub FDR_Data_get()
Dim filedate As String
Sheets("FDR Data").Select
filedate = InputBox("Enter the FDR file load date in mm-dd-yyyy format", "Date Entry")
With Sheets("FDR Data").QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\####\Desktop\Macro File\Inbox\FDR PDF Report\*" & filedate & "*" _
, Destination:=Range("A1"))
.Name = "*" & filedate & "*"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Any help would be greatly appreciated!