Back Door to VBA?

  • Thread starter Thread starter Wayne
  • Start date Start date
W

Wayne

Having "grown" a workbook over several years adding
little bits of code here and there I've made a mistake in
the code somewhere and excel closes as soon as I open the
workbook.

Is there a back door into the workbook just to look at
and alter the code?
There is no protection on the workbook or the code.
 
Open it with macros disabled.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Wayne,

Hold down the SHIFT key when you open the workbook. This prevents
the startup code from executing.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
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
 
Back
Top