+ Reply to Thread
Results 1 to 5 of 5

Changing filters in a dialog box?

  1. #1
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274

    Changing filters in a dialog box?

    Hello,

    The file filter in the following code works well. When I open the dialog box I see all the *.txt file types....

    Please Login or Register  to view this content.


    However, the new SelectFiles() function needs to be flexible enough so that I can pass it a variable and based on that variable
    I can alter the file filter. Something like this:


    Please Login or Register  to view this content.

    The above gives a runtime error 5 when FilterType = 2 ?

    However, the above works if I do:

    Please Login or Register  to view this content.
    But I need it to filter files only starting with "User" ... so all files like : "User*.h" ???

    Is there straight forwards approach to this?

    Thanks all in advance for your help!
    Rn
    Last edited by RustyNail; 05-01-2015 at 12:05 PM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: Changing filters in a dialog box?

    Not using msoFileDialogFilePicker, unfortunately.

    You can read the files of a selected directory and add them to a list on a userform if they meet your needs eg


    Please Login or Register  to view this content.
    and use code like this on the userform:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274
    Quote Originally Posted by Bernie Deitrick View Post
    Not using msoFileDialogFilePicker, unfortunately.

    You can read the files of a selected directory and add them to a list on a userform if they meet your needs eg


    Please Login or Register  to view this content.
    and use code like this on the userform:

    Please Login or Register  to view this content.
    Hi Bernie,
    For me it's quite an overkill of code ...
    I'm sort of new to VBA and wanted to keep it as
    simple as possible.

    One thing though, the only reason I wanted to
    filter the files is because I wanted the user to pick
    any file he sees but wanted to limit the files.
    in reality all I need is the path to the folder !
    I really strip off the User.h file and I use the path of
    the folder.

    So with my original code can I just go about
    getting only the path name without the user picking a file?

    For eample I saw this:

    http://software-solutions-online.com/2014/03/13/vba-save-file-dialog-filedialogmsofiledialogsaveas/

    But what does this mean:

    strPath = _

    thanks
    for your reply
    Rn
    Last edited by RustyNail; 05-01-2015 at 03:28 PM.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: Changing filters in a dialog box?

    You can get the path from the file name like this - but they do have to select a file to get a returned value.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274

    Re: Changing filters in a dialog box?

    Thanks Bernie

    I will just have to live with it for now.... let the user pick any file .....

    regards
    Rn

+ 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. Marco for changing numerous pivot chart filters at once
    By Nick Simo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2012, 12:09 PM
  2. Changing the Pivot Table Filters based on Multiple Cells
    By dbnhc8 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 08-28-2012, 02:37 PM
  3. [Macro] Excel Query Connection with Inputbox for changing filters
    By JohnGaltnl in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 07-19-2011, 04:24 AM
  4. Changing SaveAs Dialog Box
    By McNulty in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-31-2009, 11:54 AM
  5. changing options in delete dialog box
    By marthann in forum Excel General
    Replies: 1
    Last Post: 03-23-2006, 05:20 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