View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Beto[_3_] Beto[_3_] is offline
external usenet poster
 
Posts: 140
Default Importing a text file into spreadsheet

Matt wrote:

I have a text file that ...


With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;D:\JAN2004_MOMHP0000_135608.TXT", Destination:=Range("A1"))
.Name = "JAN2004_MOMHP0000_135608"


Hi,
First question: FileToOpen includes the path?

if it does try with:
"TEXT;" & FileToOpen, Destination....

Otherwise, add the path manually like:
"TEXT;D:\" & FileToOpen, Destination....

I don't know, buy the .Name property may not be needed to be changed, it
must be name assigned to the table, but it'll look better if you change
it. So if the path is not included in FileToOpen use:
.Name = Left(FileToOpen,1,len(FileToOpen)-4)
the "-4" is to strip the extension, just like the example.

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.