View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Keith[_15_] Keith[_15_] is offline
external usenet poster
 
Posts: 2
Default Importing text file

I'm trying to get a macro which imports any text file selected from a
directory C:\Data\Archive.

The recorded macro is:

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Data\Archive\Mydata.txt", Destination:=Range("A1"))
.Name = "Mydata"
etc.
This relates to a specific file whereas I want to import any text file
in that directory

I've tried lots of variations including:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Data\Archive", Destination:=Range("A1"))
.Name = Application.GetOpenFilename

but they don't work.

I'd really appreciate any ideas.

Thanks a lot