+ Reply to Thread
Results 1 to 16 of 16

Open Workbook from Same File Path with Partial Workbook Name

  1. #1
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Open Workbook from Same File Path with Partial Workbook Name

    Greetings,
    I know how to open a workbook from the same file path with the workbook's full name. However, because the workbook's name will change each month (certain dates will be added to the end of the workbook's name), I am needing to open a workbook from the same file path with a partial name. I have been working on the following code for the past few hours with no success.
    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Open Workbook from Same File Path with Partial Workbook Name

    What is the partial name?

    Is it the only other workbook in the folder?

    Can it be identified in any other way apart from the name, e.g. date/time created?

    To look for file(s) by name you should probably try using Dir or File System Object.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Norie,
    The partial name is "Garcia". There are several other workbooks in the folder. The partial name is the only way it can be identified, dates are added to the end of the name. Ex: "Garcia_6-11-19".

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Is it the only file with 'Garcia' in the name?

  5. #5
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Yes it is.

  6. #6
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Try:


    Please Login or Register  to view this content.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  7. #7
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Kokosek,
    Thank you for your reply. I tried your code and nothing happens.

  8. #8
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Check files extension: *.xlsm maybe your files have different.
    Works for me.

  9. #9
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Open Workbook from Same File Path with Partial Workbook Name

    I verified the extension is correct and still nothing. Doesn't make sense if it works for you and not for me.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Try this.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Norie,
    I added a ")" to the end of "strFileName". When i run the macro, I get a run-time error '13': Type mismatch.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Sorry, a bunch of typos in what I posted - try this.
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Norie,
    Works perfectly!!! Thank you much!!
    Kokoser,
    Thank you as well.

  14. #14
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Norie,
    I am hoping you can help me solve this issue.
    Using your code works great (and I am very appreciative) if the workbook I want to open wbGarcia was "saved" to the folder. However, if I "move" the wbGarcia to the folder, it is not recognized.

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Open Workbook from Same File Path with Partial Workbook Name

    It shouldn't matter how the workbook ended up in the folder.

    What's happening with the code when it's been 'moved'?

  16. #16
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Open Workbook from Same File Path with Partial Workbook Name

    Norie,
    I apologize for the late response, I have been traveling the last few days.
    It is working good now. Again, thank you much!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to make commandbutton to open another workbook "with file path change"
    By Rachel8226 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2019, 09:26 AM
  2. [SOLVED] Using Workbook.Open to open an excel file with a variable path
    By walt737 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2019, 01:01 PM
  3. VBA to open a workbook with partial Name
    By rhybeka in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-28-2015, 07:17 AM
  4. Replies: 5
    Last Post: 03-21-2013, 07:34 AM
  5. Macro to open a workbook from an unknown file path
    By paul_sykes00 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-03-2012, 02:42 AM
  6. How to open a workbook with partial Name?
    By ananthakumar.e in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-05-2008, 03:35 AM
  7. Get path of open workbook
    By Selina in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-29-2005, 01:50 AM

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