+ Reply to Thread
Results 1 to 6 of 6

how to process multiple files with a macro

  1. #1
    Registered User
    Join Date
    10-24-2007
    Posts
    37

    how to process multiple files with a macro

    I have created a nExcel program(main_process.xls) in reading an input file and that works fine.
    Now I have an issue with processing.
    We receive the input file on daily basis with the name store1_input.xls, store2_input.xls and so on.
    How do I code, so that
    1. the main_process.xls could open each store file individually, process it and
    at the end save it as store1_processed.xls, store2_processed.xls and so on.
    2. how to prevent all users open the file at the same time? I mean, only one user could process one store file at a time.
    For example, if store1_input.xls is opened by an user for processing, when other user attempts to open it, it should give a message "store1_input file is in process".
    Any suggestions or code highly appreciated. I am in urgent need of this.
    thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello mixel,

    Are the files all in the same folder, and are they Excel workbooks?

    Thanks,
    Leith Ross

  3. #3
    Registered User
    Join Date
    10-24-2007
    Posts
    37
    Yes, Ross. They are in c:\temp folder. I need to open each file ex. store1_input.xls, process it and save it as processed_store1_input.xls file. Continue until no more input files are found. Does it help?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello mixel,

    This macro will look for files names that start with "store" in the folder you choose. The file is then opened as new workbook. You will need to add your code that does the processing once it is opened. The file is then saved to a new folder with the new name "store_1_processed.xls". The new folder now defaults to the same folder as the workbook the macro is in.
    Please Login or Register  to view this content.
    Example of Calling the Macro
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,464
    Quote Originally Posted by mixel
    They are in c:\temp folder. I need to open each file ex. store1_input.xls, process it and save it as processed_store1_input.xls file. Continue until no more input files are found. Does it help?
    try
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-24-2007
    Posts
    37
    Thanks for the code. I will try it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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