+ Reply to Thread
Results 1 to 7 of 7

Open .docx from Excel form using partial filename

  1. #1
    Registered User
    Join Date
    09-03-2011
    Location
    Texas, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Open .docx from Excel form using partial filename

    Hi everyone,

    I am struggling with trying to open a word doc from an Excel 2007 user form using a partial file name.
    The 2007 word docs are saved in a folder named "Audit Reports" with file names like:
    123 ABC Co_CompLetter.docx
    123 ABC Co_CompReport.docx
    987 XYZ Co_RA Letter.docx
    987 XYZ Co_RA_Report.docx The number at the beginning of each file name is an Org ID Number and it is what I need to search with. What I would like to be able to do is: Enter an OrgID into an Input Box, list all files that begin with the inputted OrgID, be able to click to open the word file of interest from the list.

    Any help would be greatly appreciated.

  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 .docx from Excel form using partial filename

    Why not use Application.GetOpenFileName?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    09-03-2011
    Location
    Texas, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Open .docx from Excel form using partial filename

    Thanks for your reply.

    I tried the Application.GetOpenFilename method and it allows the user to scroll to the file name and click to open it. Problem is that the folder containing these files contains several hundred files. Is there a way to use the "OrgID" (which is the first part of each file name) so that only the files which begin with that number are listed? This would eliminate the need to scroll throughh a list of hundreds of files.

  4. #4
    Forum Contributor
    Join Date
    12-14-2013
    Location
    Tilburg, Nederland
    MS-Off Ver
    Excel 2010
    Posts
    256

    Re: Open .docx from Excel form using partial filename

    If you have that many files, is it not better to arrange the file in folders named after there "OrgID"
    Than picking the right file with the Application.GetOpenFilename will be much easier.

  5. #5
    Registered User
    Join Date
    09-03-2011
    Location
    Texas, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Open .docx from Excel form using partial filename

    Thanks for the reply.

    The folder is named "Audit Reports". It contains more than a thousand docs (two per OrgID); when the folder is opened the files are arranged by ascending OrgID number because the OrgID is at the beginning of the file name. This arrangement still requires the user to scroll down to the correct orgID and choose which of the two docs he wants. I was hoping to create a macro that would allow the user to enter an OrgID into an input box and list only the files beginning with that OrgID (or at least automatically scroll to the part of the list showing that OrgID). The user could then select which file from the two he wanted and click to open it. Is this possible?

  6. #6
    Forum Contributor
    Join Date
    12-14-2013
    Location
    Tilburg, Nederland
    MS-Off Ver
    Excel 2010
    Posts
    256

    Re: Open .docx from Excel form using partial filename

    You could put all file names on a sheet and then filter them...

    But are you aware there is some kind of filtering in the explorer? When inside the folder select first file you see and punch in the first characters of the file you need. Explorer jumps to the first file with the combination you typed in.

  7. #7
    Registered User
    Join Date
    09-03-2011
    Location
    Texas, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    (SOLVED) Open .docx from Excel form using partial filename

    Thanks,

    Solution:
    Call Shell(pathname\explorer.exe, 1)

    Windows explorer opens, user enters first few characters of file name (which are the OrgID) into the search box. User is presented only those file names which begin with the OrgID and can click to open the file selected.

+ 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. Lookup & open file based on partial filename
    By Im2bz2p345 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2011, 07:04 PM
  2. Searching for partial filename
    By daverunt in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-22-2009, 01:30 PM
  3. Partial filename search in VB
    By blackhawk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2009, 02:31 PM
  4. Searching for a Partial Filename
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-15-2006, 02:00 PM
  5. [SOLVED] How do I insert a partial filename?
    By Admin in forum Excel General
    Replies: 1
    Last Post: 11-30-2005, 09:55 PM

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