Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a spreadsheet with an external data table coming from SQL Server with a query that returns data specific to each user. I have put instructions in this file to allow it to download once and then to unlink it.

Unfortunately one user didn't, added a whole heap of data, "saved" and has lost their work.

Is there any way to get the data back?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Sorry, you are out of luck. Since you have "Remove data from the external date range before saving the workbook" checked the added data was never saved and there is no place to retrieve the user's data from.

To prevent this kind of accident going forward, I would change the workbook to macro enabled(.xlsm), if it isn't already, and add a check in the BeforeSave event to see if the table has been unlinked.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
   Dim sMsg As String

   ' Assuming the data table is the first table on the first worksheet
   With Worksheets(1).ListObjects(1)  

      If .SourceType <> xlSrcRange Then
         sMsg = "Any changes you've made to the table won't be saved unless you unlink from the database!" _
               & vbCrLf & vbCrLf & "Do you want to unlink?"
         If MsgBox(sMsg, vbExclamation + vbYesNo) = vbYes Then
            .Unlink
         End If
      End If

   End With

End Sub
share|improve this answer
    
Ah well, it was a long shot to begin with. Thanks for the macro though! =) –  Fowl Jan 25 '12 at 4:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.