S
Susan Hayes
I have finished writing my program but need help in getting the data
into sheet2. In sheet1 a command button is supposed to have the user
select a file, have the data streamed to sheet2 and delimit it using
the comma.
My first question is how can I show just *.asc with this part of the
code:
Connection:= _ "TEXT;C:\data\meth\*.ASC",
When the open file window pops up it shows txt, then I have to select
asc file type. I want to show asc files the first time without having
to select the file type. Is there anyway to remove TEXT part?
My Second question, is it possible to arrange files by date and have
the last one highlighted without actually opening it ( there are
hundreds of files)
My third question, why does the VB give a run time error 1004 when if
for example your loading a file and you press cancel. Also happens
with my inputbox(). How can I prevent this?
Any help is appreciated. Thanks
Susan Hayes
I have the following code:
With Worksheets("data1").Activate
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\data\meth\*.ASC",
Destination:=Sheets("Data1").Range("A1") _
)
'.Name = "222003-M"
'.FieldNames = True
'.RowNumbers = False
'.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
'.SavePassword = False
'.SaveData = True
.AdjustColumnWidth = True
'.RefreshPeriod = 0
.TextFilePromptOnRefresh = True
'.TextFilePlatform = 1252
.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, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
'.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End With
into sheet2. In sheet1 a command button is supposed to have the user
select a file, have the data streamed to sheet2 and delimit it using
the comma.
My first question is how can I show just *.asc with this part of the
code:
Connection:= _ "TEXT;C:\data\meth\*.ASC",
When the open file window pops up it shows txt, then I have to select
asc file type. I want to show asc files the first time without having
to select the file type. Is there anyway to remove TEXT part?
My Second question, is it possible to arrange files by date and have
the last one highlighted without actually opening it ( there are
hundreds of files)
My third question, why does the VB give a run time error 1004 when if
for example your loading a file and you press cancel. Also happens
with my inputbox(). How can I prevent this?
Any help is appreciated. Thanks
Susan Hayes
I have the following code:
With Worksheets("data1").Activate
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\data\meth\*.ASC",
Destination:=Sheets("Data1").Range("A1") _
)
'.Name = "222003-M"
'.FieldNames = True
'.RowNumbers = False
'.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
'.SavePassword = False
'.SaveData = True
.AdjustColumnWidth = True
'.RefreshPeriod = 0
.TextFilePromptOnRefresh = True
'.TextFilePlatform = 1252
.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, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
'.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End With