+ Reply to Thread
Results 1 to 8 of 8

VBA Automatically Open Files In Folder

  1. #1
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    VBA Automatically Open Files In Folder

    Hi, I wonder whether someone may be able to help me please.

    I'm using the script below to allow a user to open multiple files, extracting a range of information before pasting this into a "Summary" sheet.

    Please Login or Register  to view this content.
    In it's current for, the user has to select each file to open, but I'd like to adapt this so the user only has to select the folder and the files open automatically and extract the data, but I'm very unsure about how to do this.

    I just wondered whether someone could possibly look at this and offer some guidance on how I may go about amending this.

    Many thanks and kind regards

  2. #2
    Forum Contributor
    Join Date
    05-10-2012
    Location
    Paris, France
    MS-Off Ver
    2016/365
    Posts
    123

    Lightbulb Re: VBA Automatically Open Files In Folder

    Hi Hobbiton73

    Try this code
    Please Login or Register  to view this content.
    See you later

  3. #3
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Automatically Open Files In Folder

    Hi @BrianM45, thank you for taking the time to reply to my post and for putting the solution together.

    I've tried the code you kindly provide, but unfortunately I receive a Run time '1004' error with the message "Sorry, we couldn't find File1.xls. Is it possible it was moved, renamed or deleted". Debug then points to this line:
    Please Login or Register  to view this content.
    This is a little puzzling though because File1 does exist and is in the folder I choose.

    Kind regards

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: VBA Automatically Open Files In Folder

    sFile just appears to be a file name and not a full path. Suggest incorporating the path as well.
    Martin

  5. #5
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Automatically Open Files In Folder

    Hi @mrice, thank you for taking the time to reply to my post.

    Forgive me for askng, but could you possibly offer a little guidance how I may incorporate the full file path please.

    Many thanks and kind regards

  6. #6
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: VBA Automatically Open Files In Folder

    Try

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    05-10-2012
    Location
    Paris, France
    MS-Off Ver
    2016/365
    Posts
    123

    Re: VBA Automatically Open Files In Folder

    Hi Hobbiton, Hi Mrice

    sPath return the path who choose whit back slash
    sFile is the file who is in the directory

    The correct code is
    Please Login or Register  to view this content.


    Sorry for my late reply

  8. #8
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Automatically Open Files In Folder

    Hi @BrianM45,@mrice,thank you both for taking the time to come back to me with this.

    @BrianM45, your amended ccode works great, thank you.

    Both, all the best and kind regards

+ 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] Excel VBA code for selecting a folder then search & open specified files in that folder
    By Excelrookie_1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2021, 03:09 AM
  2. [SOLVED] Open all files in folder automatically using VBA
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-10-2013, 02:43 AM
  3. [SOLVED] VBA Code open files in folder, copy text to workbook-Next time folder opened copy only new
    By Bikeman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-02-2013, 07:59 PM
  4. [SOLVED] Open all files in a SharePoint folder (Problem: Files open out of order)
    By holmstarrunner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2012, 10:13 AM
  5. Open files in folder - skip if already open
    By Steph in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-25-2005, 03:06 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