Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Reading TSv files in Excel

Hi!

I would like to read a TSV file in Excel. It is quite a big process I
want to make, so let's being in steps.

My first question is how I can search into a folder and select the last
modified TSv file.

i recorded already a macro, the code is showed just belown. So, how can
I change my code to make it happen that Excel is reading in my last
modified file?

Thanx

Code:

Sub TSV_File()
'
' TSV_File Macro
' Macro recorded 2006-09-29 by Bernard Wesseling
'

'
ChDir "H:\Model folder\results"
Workbooks.OpenText Filename:= _
"H:\Model folder\results\TEA5760_HN_2006 Sep 29.tsv",
Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 2),
Array(2, 2), _
Array(3, 2), Array(4, 2), Array(5, 1), Array(6, 1), Array(7,
2), Array(8, 2), Array(9, 1), _
Array(10, 2), Array(11, 2), Array(12, 2), Array(13, 1))
Range("A1:L1").Select
Selection.Columns.AutoFit
Rows("3:3").Select
ActiveWindow.FreezePanes = True
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Reading TSv files in Excel

For finding and working with file, look into use Dir() and FileDateTime().
e.g. something like this

Dim FileName as string
dim ThisFileTime as double
dim OldestFileName as string
dim OldestFileTime as double

filename=Dir(PathToYourFolder & "\*.tsv)
do until filename=""
ThisFileTime=filedatetime(PathToYourFolder & "\" & filename)
if ThisFileTime<OldestFileTime then
OldestFileTime= ThisFileTime
OldestFileName =filename
end if
loop

By TSV, I assume you mean a Tab separated Value file. Excel can import these
pretty easily.

NickHK

wrote in message
oups.com...
Hi!

I would like to read a TSV file in Excel. It is quite a big process I
want to make, so let's being in steps.

My first question is how I can search into a folder and select the last
modified TSv file.

i recorded already a macro, the code is showed just belown. So, how can
I change my code to make it happen that Excel is reading in my last
modified file?

Thanx

Code:

Sub TSV_File()
'
' TSV_File Macro
' Macro recorded 2006-09-29 by Bernard Wesseling
'

'
ChDir "H:\Model folder\results"
Workbooks.OpenText Filename:= _
"H:\Model folder\results\TEA5760_HN_2006 Sep 29.tsv",
Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 2),
Array(2, 2), _
Array(3, 2), Array(4, 2), Array(5, 1), Array(6, 1), Array(7,
2), Array(8, 2), Array(9, 1), _
Array(10, 2), Array(11, 2), Array(12, 2), Array(13, 1))
Range("A1:L1").Select
Selection.Columns.AutoFit
Rows("3:3").Select
ActiveWindow.FreezePanes = True
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reading .sxls files in Office XP 2002 Excel 2002 Excel user Excel Discussion (Misc queries) 2 January 25th 09 09:24 PM
Reading data from other files Incoherent Excel Programming 0 January 2nd 06 07:55 AM
Reading dbf files Luis Verme Excel Discussion (Misc queries) 6 July 1st 05 01:32 AM
Reading dbf files Luis Verme Excel Programming 6 July 1st 05 01:32 AM
Reading all files in a folder H. Rye Excel Programming 1 January 20th 04 02:15 PM


All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"