View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robbie[_2_] Robbie[_2_] is offline
external usenet poster
 
Posts: 3
Default Text Import Wizard


-----Original Message-----
Is there an easy way of programmatically importing a
delimits text files (similar to the Text Import Wizard
but no dialog)? Fixed/Delimited, setting the delimiter,
etc.
.


Yes--here's a snippet from something that does just that:


Set QuerySheet = Sheets.Add
With QuerySheet.QueryTables.Add(Connection:=FileAddress (i,
1), Destination:=QuerySheet.Range("A1"))
..TextFileCommaDelimiter = True
..Refresh BackgroundQuery:=False
End With

QuerySheet has been declared as Worksheet, i is the index
for a loop, and FileAddress is a string array containing
file addresses. For more info look up the Add method of
QueryTables in the VBA help files.

Robbie