+ Reply to Thread
Results 1 to 3 of 3

Problem to re-open original file after save as macro has run

  1. #1
    Registered User
    Join Date
    06-28-2012
    Location
    Argentina
    MS-Off Ver
    Excel 2007
    Posts
    2

    Problem to re-open original file after save as macro has run

    Hi, I'm new to the Forum and in need of help with a basic macro I'm trying to create. The aim of the macro is to save a new file from an existing one, close this newly created file and after that, open the original file again (the file from where the new one was created). I got the save as and closing the file parts working fine but can't seem to get the original workbook re-opened. Below you'll find the code:

    Please Login or Register  to view this content.
    Any ideas of what I'm doing wrong?

    Thanks a lot in advance, I really appreciate all the hard work you people do here
    Best regards!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Problem to re-open original file after save as macro has run

    Hi,

    It looks like you are closing the workbook that contains the code for the workbook you are trying to open.

    Try creating a workbook variable - say Dim wbTemp As Workbook and set it before you Save the workbook. i.e. Set wbTemp = Activeworkbook

    Then open the myWorkbook file and finally close the wbTemp workbook that you've saved with wbTemp.Close.

    One other thought. For cases like this you should be creating a blank Template file .xltm type file rather than using a standard .xlsm blank file. When you open the template a subsequent save does not ovewrite the template (unless you deliberately choose to do so) but saves the file with a regular .xlsm extension. It would avoid the problem you've encountered.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    06-28-2012
    Location
    Argentina
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Problem to re-open original file after save as macro has run

    Thanks for your prompt remply and help, Richard. I'll try to use a template file as you suggest to see if I find it simpler.

    Thanks a lot!

+ 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