command to import a file into excel

  • Thread starter Thread starter vikram
  • Start date Start date
V

vikram

i have made an excel file wherein i hve a command button and when
click that command button, a common dolog box opens and i select a tex
file, now i have selected a text file, i want to import it int
excel,,how would i do that

i have attached the file...


please let me know thank

Attachment filename: vikrama.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=54352
 
assume the variable fname holds the fully qualified path as returned by your
common dialog.

Workbooks.Open Filename:=fname

If you want special treatment of the text file, look at
Workbooks.OpenText Filename:=fname, . . . additional arguments - see help .
.. .
 
Sorry, if you want to import it into an existing document, turn on the macro
recorder while you manually do

Data=>Get External Data => Import Text file

and import a text file.

Then turn off the macro recorder and replace the hardcoded file name with
the variable fName or whatever variable holds the fully qualified name of
the file.
 
Back
Top