+ Reply to Thread
Results 1 to 5 of 5

Choosing folder path (instead of file path) in VBA

  1. #1
    Registered User
    Join Date
    05-22-2014
    Posts
    6

    Choosing folder path (instead of file path) in VBA

    Hello,

    I have a program in VBA that modifies other files that are within the same folder (using ThisWorkbook.Path). I would like to add a feature to the program that allows the user to select a different folder using a dialog box, so that files in other directories can be modified also. Something very similar to Application.GetOpenFilename would be ideal, but would allow me to select a folder instead of an individual file. Many thanks for any insight you can offer.

  2. #2
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Choosing folder path (instead of file path) in VBA

    Hi sminter

    Perhaps this
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    05-22-2014
    Posts
    6

    Re: Choosing folder path (instead of file path) in VBA

    Thank you for your reply. Upon executing your code, I got an error message saying "Object required." I've used objects once in the past, but I'm not sure how to set an object to work with this example. Just to try various modifications, I commented out the "Option explicit" line, and the object error disappeared, but I got a new error that said "Variable not defined," and highlighted the "application..." line in the "with" statement. I imagine that the first error is the one to focus on. Is there a way to add an object to your code? Thanks again.

  4. #4
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Choosing folder path (instead of file path) in VBA

    Hi sminter

    It works for me...see attached.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-22-2014
    Posts
    6

    Re: Choosing folder path (instead of file path) in VBA

    Right you are, it must be something in my file interfering with it. When I start from scratch, it works like a champ. Thanks so very 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. [SOLVED] file name from folder path
    By Sundarvlr in forum Excel General
    Replies: 3
    Last Post: 04-17-2014, 01:36 PM
  2. Code to list the folder path and sub folder path of a specific file
    By kalai1587 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2013, 03:51 AM
  3. [SOLVED] Save As Dialog Box - Default Path and File Name, User Selects Sub Folder from Default Path
    By christenprochaska in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-12-2012, 05:17 PM
  4. Specified folder path to select file path
    By JayEmTee91 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2012, 10:38 AM
  5. Replies: 7
    Last Post: 10-09-2009, 10:10 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