+ Reply to Thread
Results 1 to 5 of 5

File Save As - multiple instances of Excel

  1. #1
    Registered User
    Join Date
    06-27-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    File Save As - multiple instances of Excel

    I have a situation where a section of my macro code needs to be used multiple times (for different inputs), with a separate output Excel file create for each input.

    See code attached.

    The problem I am facing is that the macro shuts down after processing the 1st line of input. I am guessing it is because the ActiveWorkbook.SaveAs command is creating the output file in the same instance of excel.

    How do I keep the original macro workbook open in order to process next line of txt file input? Do I have open a new instance of Excel for each line of input? I also need a way to automatically close the macro workbook after all lines of input have been processed.

    Any help would be much appreciated. Thanks.

    Please Login or Register  to view this content.

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

    Re: File Save As - multiple instances of Excel

    Try SaveCopyAs
    Martin

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: File Save As - multiple instances of Excel

    Please Login or Register  to view this content.
    I can't see where you get var1 & var 2 from.



  4. #4
    Registered User
    Join Date
    06-27-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: File Save As - multiple instances of Excel

    snb - Thanks for your suggestion. Sorry if my question was not clear - I already have the code to populate var1 & var2 based on the input file.
    What I am looking for is a way to keep the macro file open while creating new optput files for each line of input. My macro is closing after processing the 1st line of input.


    mrice - your suggestion did not work. "I got a Compile error in hidden module:Module1" when I tried SaveCopyAs.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: File Save As - multiple instances of Excel

    'optput' is new to me....

    Please Login or Register  to view this content.

+ 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