I would visit the following sites to deal with backing up your
workbook(s).
David McRitchie
http://www.mvps.org/dmcritchie/excel/backup.htm
AutoSafe.zip
http://www.bmsltd.co.uk/mvp/MVPPage.asp#JanKarelPieterse
-------------------------------------------------------------------------------------------
After you've opened the workbook using the suggestions provided, you
may want to try to adapt the following code to 'backup' your code.
Watch the linewrap.
Sub ExportAllVBA(Optional varName As Variant)
'' Exports all Modules, etc. to folder named the same as the Workbook.
Dim VBComp As VBIDE.VBComponent
Dim PartPath As String
Dim NextPartPath As String
Dim TotalPath As String
Dim Sfx As String
Dim d As Integer
If IsMissing(varName) Then varName = ActiveWorkbook.Name Else
varName = CStr(varName)
PartPath = "C:\Money Files\Computer Helpers\Modules\"
NextPartPath = Left$(ActiveWorkbook.Name, Len(ActiveWorkbook.Name)
- 4)
On Error Resume Next
TotalPath = PartPath & NextPartPath
ChDir TotalPath
If Err.Number = 76 Then MkDir TotalPath
On Error GoTo errHandler
For Each VBComp In ActiveWorkbook.VBProject.VBComponents
Select Case VBComp.Type
Case vbext_ct_ClassModule, vbext_ct_Document
Sfx = ".cls"
Case vbext_ct_MSForm
Sfx = ".frm"
Case vbext_ct_StdModule
Sfx = ".bas"
Case Else
Sfx = ""
End Select
If Sfx <> "" Then
VBComp.Export _
Filename:=PartPath & NextPartPath & "\" & VBComp.Name &
Sfx
End If
Next VBComp
Exit Sub
errHandler:
MsgBox "The reason for this message:" & vbCrLf & "The Error Number
is: " & Err.Number _
& vbCrLf & "The Error Description is: " & Err.Description
End Sub
HTH
Paul