+ Reply to Thread
Results 1 to 9 of 9

Save a copy of Workbook on Close to a different folder.

  1. #1
    Registered User
    Join Date
    02-25-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    43

    Save a copy of Workbook on Close to a different folder.

    Dear Guys,
    I've got a Workbook "F:\MyFolder\Cost.xlsm" where I'd like to be a code which would enable me to save a copy of this workbook to a different folder On Close and the copy should be A MACRO FREE WORKBOOK (e.g. "F:\CopyCost.xlsx"). I've created the following code, but it produces a workbook which cannot be opened. Help please---
    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Save a copy of Workbook on Close to a different folder.

    Try this. It assumes there is no vba code in the worksheet code modules.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    02-25-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Save a copy of Workbook on Close to a different folder.

    AlphaFrog,
    Firstly, that code creates an empty workbook. Secondly, it saves the workbook to the same directory, whereas that should be saved in a different one "f:\CopyCost.xlsx".

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Save a copy of Workbook on Close to a different folder.

    It worked for me in my test. Copied the workbook as a macro free workbook to a different folder. The sheets were not blank.

  5. #5
    Registered User
    Join Date
    02-25-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Save a copy of Workbook on Close to a different folder.

    AlphaFrog
    I have made little alteration to your code. Now it seems to work fine.
    Please Login or Register  to view this content.
    Thanks.
    Just one more question - What was wrong with "ThisWorkbook.SaveCopyAs "F:\CopyCost.xlsx" function?"
    Should I mark this as Solved?
    Last edited by bubai; 11-01-2017 at 04:33 AM. Reason: Forgot to post

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Save a copy of Workbook on Close to a different folder.

    You're welcome.

    - Just re-naming an existing workbook with the .xlsx extension doesn't strip it of macro code and it doesn't change it to the .xlsx format.
    - The .SaveCopyAs function cannot save a copy as different file format. It wouldn't be a copy then.

    Should you mark this as solved? Only you can answer that.

  7. #7
    Registered User
    Join Date
    02-25-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Save a copy of Workbook on Close to a different folder.

    AlphaFrog,
    Marking it unsolved as i've got 2 questions.
    1. Why there is no Paste Method but only Copy Method "Sheets.Copy".
    2. What method should i add to the code if i'd like to save the copy of the workbook without any formula. Just with values.

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Save a copy of Workbook on Close to a different folder.

    1.) Highlight the word Copy in your VBA code editor and press F1 for help on that topic. Under the applies to Sheets section in the Remarks area gives an explanation of its usage for this instance.

    2.)
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-25-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Save a copy of Workbook on Close to a different folder.

    Thaks a lot AlphaFrog.

+ 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. Open workbook copy&paste, save and close Repeat
    By JPSIMMON in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2016, 12:29 PM
  2. Replies: 3
    Last Post: 10-17-2015, 02:05 PM
  3. trying to copy and save workbook to different folder
    By Jenkins27 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-14-2015, 02:02 AM
  4. How to copy Sheet to a new workbook and save to a specific folder
    By moxman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2014, 07:43 PM
  5. Save entire workbook as copy in specific folder with VBA
    By cychua in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-01-2012, 08:35 AM
  6. Open workbook, copy data, save and close error
    By Jessica.Bush in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-01-2012, 12:59 PM
  7. macro to save copy of workbook in a named folder
    By famico78 in forum Excel General
    Replies: 0
    Last Post: 10-01-2009, 08:38 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