The routine I was suggesting didn't use a querytable. It would just open the
file. Then you could copy and paste to whereever you wanted to. (Delete any
existing data first if you want.)
"jln via OfficeKB.com" wrote:
Ok im getting closer
here is what i have
Problem is on this line
With ActiveSheet.QueryTables.Add(Connection:=myFileName , Destination:=Range
("A1")) '
Option Explicit
Sub Mgicimport()
'
' Macro6 Macro
' Macro recorded 11/6/2006 by J928052
'
'
Dim myFileName As Variant
myFileName = Application.GetOpenFilename(filefilter:="CSV Files, *.CSV",
_
Title:="Pick a File")
If myFileName = False Then
MsgBox "Ok, try later" 'user hit cancel
Exit Sub
End If
Workbooks.Open Filename:=myFileName '....rest of recorded code here!
ActiveWorkbook.Worksheets.Add
With ActiveSheet.QueryTables.Add(Connection:=myFileName , Destination:
=Range("A1")) ' Problem is HERE
.Name = ""
.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 = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200611/1
--
Dave Peterson