+ Reply to Thread
Results 1 to 7 of 7

Macro to open/close/save workbook

  1. #1
    Registered User
    Join Date
    08-06-2013
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2003
    Posts
    72

    Macro to open/close/save workbook

    So here is my problem. I need to have a workbook (all of them in a folder, ideally) refresh in the middle of the night. The file is large so the refresh takes a full minute. I know I can't auto refresh a closed workbook (pretty sure anyway), and I can't leave the workbook open for various reasons.

    So I'm thinking I could have a macro in an open excel (it kicks off on open) that will open a particular workbook elsewhere (the one I need refreshed), open it, refresh it and close/save it. Ideally it would do this for the entire group of workbooks in the folder but I'd be happy to start with just one. I would like to set it to occur every twelve hours (so at midnight, say, this would occur - I would just have to leave the workbook with the macro in it open on a computer so that it runs and completes this task every night).

    Is this possible? Any ideas/workarounds?

    Thanks!

  2. #2
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Macro to open/close/save workbook

    have all the workbooks to refresh on open, then create a VBA to open, wait for completion, and save each of the workbooks. is this what you want?
    Click on the star if you think I helped you

  3. #3
    Registered User
    Join Date
    08-06-2013
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2003
    Posts
    72

    Re: Macro to open/close/save workbook

    I don't want the workbooks I need to refresh to do so on open but to have another macro open them, refresh them and then close them. So from a workbook on my computer, the macro would go into another drive, open the file refresh, save/close. Does that make sense? Sorry if this is confusing. The reason the macro has to be from a separate workbook is because I want the workbooks that I need to refresh to do so in the middle of the night when nobody is at work.

  4. #4
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Macro to open/close/save workbook

    I understand that but what I was suggesting is to have each workbook set to Autorefresh (refresh on open). then with your Macro you just open them and save/closed them.

  5. #5
    Registered User
    Join Date
    08-06-2013
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2003
    Posts
    72

    Re: Macro to open/close/save workbook

    Oh gotcha. Yes, that would be much easier....but there's a few reasons it wouldnt' work for this particular project. For one, if it refreshes on open THEN they input data it won't refresh again until they open it again. So if they open it on a friday (it refreshes), then they enter data and close it....until they open it again on Monday it won't refresh (and it won't update the charts etc. the workbooks are linked to). I could set it to refresh every 30 seconds etc. but lke I said it's a large file and it takes a min. or more to refresh, so this might screw them up.

  6. #6
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Macro to open/close/save workbook

    oops. I typed the wrong answer.

  7. #7
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Macro to open/close/save workbook

    I understand what you say. but, to help your macro from your control worksheet (the one that opens, saves all the others) you can set all others to refresh on open and then you only need to create a macro for opening and closing them, without bothering to create code for refreshing them also.
    Your macro would contain something like this
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    08-06-2013
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2003
    Posts
    72

    Re: Macro to open/close/save workbook

    Works great, thanks so 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. Replies: 1
    Last Post: 12-26-2013, 04:55 AM
  2. How to open,save and close another workbook from the current workbook using macro?
    By ravikumar00008 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2012, 10:42 AM
  3. 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
  4. Save an open workbook, then open template workbook and close the saved workbook
    By ondvirg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2009, 10:20 PM
  5. Macro to open workbook, run macro, save, and close.
    By rclark430 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2008, 08:07 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