+ Reply to Thread
Results 1 to 9 of 9

Macro to open file with specific name from cell

  1. #1
    Registered User
    Join Date
    08-26-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    58

    Macro to open file with specific name from cell

    Hi,

    I have a piece of code which is intended to open some specific file. the file name comes from a cell. My problem is, I wanted to VBA to see the value from cell, search the entire folder and open the file where the file name contains the cell value.

    > If cell value is 4546 then it opens "4546.xls"

    I wanted it to be

    > if cell value is 4546 it can open file names like "4546_sadsd.xls" or "sdfhjdfs_4546.xls" or "sfsdfs_4546_safdsfs.xls"

    I am using wildcard for it but it seems that it is not working.

    Also one more point. The file wanted to open is having links to other files. So when the VBA trys to open that, it asks for whether to Update or not. I don't want that pop-up to be showed. I have applied the Application.DisplayAlerts = false but its not working. Any idea why?

    Any help will be greatly appreciated.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to open file with specific name from cell

    Try this...

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-26-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: Macro to open file with specific name from cell

    Sorry....its not working......
    Is it working for you? I have also tried several things in the same way but it seems that nothing is working.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to open file with specific name from cell

    Yes it works for me.

    What exactly do you mean by "its not working"? Does it error? Not find a file? What?

    Did you use this exact code?

    What exactly is in Cells(3,3) ?

  5. #5
    Registered User
    Join Date
    08-26-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: Macro to open file with specific name from cell

    Thanks a lot for your assistance..

    Yes. I have used the exact code of yours. It says file not found. Find the ZIP file which contains all the things with the screenshots.

    regards
    Sbehera
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to open file with specific name from cell

    It works for me using your Master.xls file.

    If you're using a Mac, this wont work.

    Is your Master.xls file saved in the same folder as your 629_abcdef.xls file? It should be with this code.

  7. #7
    Registered User
    Join Date
    08-26-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: Macro to open file with specific name from cell

    Yes... The 629_abcdef.xls is saved in the same folder and I am using windows...

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to open file with specific name from cell

    Is your 629 file an .xlsx or .xlsm file?

    If yes, try this...
    MYFLNAME = "*" & Cells(3, 3).Value & "*.xls*"

    Otherwise, I'm stumped.

  9. #9
    Registered User
    Join Date
    08-26-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: Macro to open file with specific name from cell

    Hi AlphaFrog , Once again thanks a lot for your patience and efforts.. Finally i have figured out what was going wrong. When I changed the highlighted to MYPTH, It is doing as good as it should..thanks lot...



    Please Login or Register  to view this content.

+ 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