+ Reply to Thread
Results 1 to 4 of 4

Macro won’t open file it had created earlier

  1. #1
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Florida
    MS-Off Ver
    Home -Excel 2007, Work 2016
    Posts
    254

    Macro won’t open file it had created earlier

    Simplified:
    File named A saved
    Macros changes some data in it and name is changed to B and saved
    Want to open A while closing B
    Can not get A to open

    This macro saves a file full of data
    #ThisWorkbook.SaveAs ThisWorkbook.Path & Application.PathSeparator & Sheet1.Range("C41") & (" - ") & Sheet1.Range("C39") & ("- Release of Draw # ") & Sheet1.Range(" C50") & ".xlsm"#

    Data is then summarized as to $ paid to date, new balance.
    C50 is increased by 1.
    This macro then saves the updated file.
    #ThisWorkbook.SaveAs ThisWorkbook.Path & Application.PathSeparator & Sheet1.Range("C41") & ("-") & Sheet1.Range("C39") & ("- Ready to insert Draw # ") & Sheet1.Range("C50") & (" data") & ".xlsm"#

    I want to open the file created by the first SaveAs above and at the same time close the second

    My macro to open what was save in macro 1 above that I can not get to work to open is:
    #Workbook.Open filename:=Sheet1.Range("C41") & (" - ") & Sheet1.Range("C39") & ("- Release of Draw # ") & Sheet1.Range(" C50") - 1 & ".xls""#

    Is there an obvious problem in my Workbook.open statement??
    Last edited by ILoveStMartin; 12-16-2019 at 01:09 PM. Reason: Need to enclose data w #

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Workbook saved.. Data changed - File saved w another name. Need to open first but can'

    Please Login or Register  to view this content.
    Is this just a typo because it only needs to be 1 double quote at the end .
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Florida
    MS-Off Ver
    Home -Excel 2007, Work 2016
    Posts
    254

    Re: Workbook saved.. Data changed - File saved w another name. Need to open first but can'

    Typo - Thanks
    Note - Just realzed I want it to open as an XLS file - not a xlsm
    Going to change my post to show that

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,443

    Re: Workbook saved.. Data changed - File saved w another name. Need to open first but can'

    @ILoveStMartin
    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

+ 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. Data entered, saved, close file, open file data gone
    By witchypoo in forum Excel General
    Replies: 1
    Last Post: 03-23-2019, 08:16 AM
  2. Copy worksheets (names, data and format) from saved data file to open active workbook
    By cdtouchberry in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2019, 07:51 PM
  3. Replies: 0
    Last Post: 02-09-2016, 06:14 PM
  4. Inputbox data saved to two cells and workbook saved as template
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-06-2014, 02:42 PM
  5. how to get data from saved workbook that is also currently open?
    By seron in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-01-2007, 02:23 PM
  6. [SOLVED] How do I restore a previous version of a file I changed and saved
    By C Becker in forum Excel General
    Replies: 2
    Last Post: 05-16-2006, 04:30 PM
  7. [SOLVED] recover a file in excel that has been changed and saved
    By unsave excel worksheets in forum Excel General
    Replies: 6
    Last Post: 04-14-2006, 02:25 PM

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