+ Reply to Thread
Results 1 to 3 of 3

use of wild card in file name.

  1. #1
    Forum Contributor
    Join Date
    01-10-2006
    Location
    Ahmedabad, India
    MS-Off Ver
    Office 2000
    Posts
    346

    use of wild card in file name.

    I have a text file in a directory and I want to read the file to an EXCEL worksheet. File name is not fixed but it a text file and it is the only text file in the directory. I would like to use wild card * as name of the file. It does not work. eg
    file_name = "d:\test\*.txt"
    Open file_name For Input As #1
    Apparently we must give the name such as d:\test\abcd.txt. Since I do not always know the name of file I cannot hard code the name in the sub. I want to tell the prog to access the text file in directory "d:\test\". If I could use a wild card ( *.txt) it would have been great.

    Any suggestion?

    A V Veerkar

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    It is not a wild card but a variable you need ...
    Once you have declared it, you can set it by retrieving from wherever it is stored ...
    HTH
    Carim


    Top Excel Links

  3. #3
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    You can do so:

    file_name = dir ("d:\test\*.txt"
    and then:
    open "d:\test\" & file_name for input as #1

    you can also read all text files:

    Please Login or Register  to view this content.
    Regards,
    Antonio

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1