+ Reply to Thread
Results 1 to 7 of 7

how to retrieve a file

  1. #1
    Forum Contributor
    Join Date
    10-27-2010
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    107

    how to retrieve a file

    retrieve.JPG

    From the picture we can see a combobox and a button. What I need to do now is that once I select a combobox and hit the button. I should able to retrieve a file by the name that is exactly same as the combobox name. For e.g. when I select apple combobox, I should able to select a file name that must be apple.txt. And the user has the freedom to choose the location of the file (e.g. the file can be in C drive or D drive or any other folder). I managed to create these codes,

    Please Login or Register  to view this content.
    From this code, the user can choose the file from any location. But at the same time he can also any .txt file, which what I want to avoid.

    Important:
    * File I want to retrieve is in .txt format
    * the user must have full freedom in choosing the file location
    * But he can only select a .txt file name that is exactly same as to the combobox he select (e.g. if he select apple for the combobox then, he can only open a file name that goes by apple.txt)
    Last edited by darkhorse4321; 10-27-2010 at 11:27 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: how to retrieve a file

    Hello darkhorse4321,

    Where is this macro located? Is the macro code for the CommandButton? Please post all the code.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    10-27-2010
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    107

    Re: how to retrieve a file

    hi i have included the entire code.

  4. #4
    Forum Contributor
    Join Date
    10-27-2010
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    107

    Re: how to retrieve a file

    hi i have included the entire code.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: how to retrieve a file

    Hello darkhorse4321,

    Here is the updated version of your macro.
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    10-27-2010
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    107

    Re: how to retrieve a file

    Thanks a lot.Your codes worked. Just needed to edit a line of yours to this,

    If StrComp(myFileName, Filename + ".txt", vbTextCompare) <> 0 Then
    if i don't add + ".txt", the two files will not be comparable and therefore the file will not open.

  7. #7
    Forum Contributor
    Join Date
    10-27-2010
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    107

    Re: how to retrieve a file

    Hi Leith Ross, by the way i added to your rep but i don't know how to make this thread solved. I can't see any [solved] button around.hahah

+ 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