+ Reply to Thread
Results 1 to 6 of 6

Excel 2013 Refreshall then save does not save changes

Hybrid View

  1. #1
    Registered User
    Join Date
    02-25-2013
    Location
    Cleveland, OH
    MS-Off Ver
    Excel 2010
    Posts
    4

    Excel 2013 Refreshall then save does not save changes

    I have several spreadsheets that are on a SharePoint site that contain connections to a SharePoint list. Each sheet contains multiple connections. I need to automate the process to open each spreadsheet, perform a RefreshAll then save the spreadsheet. The VBA code works perfectly if I step through it using F8 but if I let it run it appears to go through the refresh (I see the messages showing the connections), it saves the file but the saved file does not contain the refreshed data. I added an Application.Wait in case the refresh was not complete but that did not help. I have searched for similar issues but did not find anything. Any help would be appreciated.

    Sub RefreshWorksheets()
    '
    ' RefreshWorksheets Macro
    ' Refresh all worksheets in the Summary Documents library
    '
        Dim ActiveWks
        Dim PathName
        Dim FolderName
        Dim FileName
            
        
        ActiveWks = ActiveWorkbook.Name
        
        FolderName = "Folder1"
        RefreshSheet1 FolderName
        RefreshSheet2 FolderName
        
        FolderName = "Folder2"
        RefreshSheet1 FolderName
        RefreshSheet2 FolderName
        
        FolderName = "Folder3"
        RefreshSheet1 FolderName
        RefreshSheet2 FolderName
           
        Windows(ActiveWks).Activate
        Application.ActiveWindow.Close SaveChanges:=True
        Application.Quit
    
    End Sub
    
    
    Sub RefreshSheet1(FolderName)
        
        Dim WksPath
        Dim FileName
        
        WksPath = "//xxx.com/sites/mysite/coll/SummaryDocuments/" & FolderName & " Summaries/" & FolderName & " Review and Success Ratings.xlsx"
        FileName = FolderName & " Review and Success Ratings.xlsx"
        On Error GoTo ErrorHandler1:
        Workbooks.Open FileName:=WksPath
        Workbooks(FileName).Activate
        ActiveWorkbook.RefreshAll
        Application.Wait (Now + TimeValue("00:01:30"))
        ActiveWorkbook.Close SaveChanges:=True
        
    ErrorHandler1:
        Exit Sub
    
    End Sub
    
    
    Sub RefreshSheet2(FolderName)
        
        Dim WksPath
        Dim FileName
          
        WksPath = "//xxx.com/sites/mysite/coll/SummaryDocuments/" & FolderName & " Summaries/" & FolderName & " Executive Summary.xlsx"
        FileName = FolderName & " Executive Summary.xlsx"
        On Error GoTo ErrorHandler2:
        Workbooks.Open FileName:=WksPath
        Workbooks(FileName).Activate
        ActiveWorkbook.RefreshAll
        Application.Wait (Now + TimeValue("00:01:30"))
        ActiveWorkbook.Close SaveChanges:=True
        
    ErrorHandler2:
        Exit Sub
    
    End Sub

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Excel 2013 Refreshall then save does not save changes

    Try adding a DoEvents after the RefreshAll.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    02-25-2013
    Location
    Cleveland, OH
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Excel 2013 Refreshall then save does not save changes

    Thank you for the suggestion but that did not work. I tried before and after the Application.Wait and I tried taking the Application.Wait away and the saved file does not contain the updated information.

  4. #4
    Registered User
    Join Date
    02-25-2013
    Location
    Cleveland, OH
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Excel 2013 Refreshall then save does not save changes

    I increased the wait time to 2 minutes and it seems to be working now. Thanks for your assistance.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Excel 2013 Refreshall then save does not save changes

    As it appears you've reached a conclusion, I've marked this thread SOLVED for you.
    FYI, this is done through the Thread Tools located above the first post in this thread. Thanks.

  6. #6
    Registered User
    Join Date
    02-25-2013
    Location
    Cleveland, OH
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Excel 2013 Refreshall then save does not save changes

    Thank you! I could not find the way to mark it solved.

+ 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: 4
    Last Post: 05-06-2014, 11:35 AM
  2. [SOLVED] Save As condition using 2 Method 2013
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-18-2014, 04:53 PM
  3. Excel 2013 - Save As Webpage
    By NeedForExcel in forum Excel General
    Replies: 0
    Last Post: 03-16-2014, 10:47 PM
  4. Save as fail with excel 2010 and 2013
    By graiggoriz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-19-2013, 08:18 AM
  5. Need to pause between a RefreshAll and Save commands
    By tigerrv in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2012, 04:42 PM

Tags for this Thread

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