Published in: Visual Basic
under Tools-References add "Microsoft Visual Basic for Applications Extensibility 5.3" as a reference
Sub ExportAllVBA() Dim VBComp As VBIDE.VBComponent Dim Sfx As String 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:=ActiveWorkbook.path & "\" & VBComp.name & Sfx End If Next VBComp End Sub Public Function FileExists(sFilePath As String) As Boolean If Trim(sFilePath) = "" Then Exit Function If Right(sFilePath, 1) = "\" Then Exit Function '// ------------------------------------------------------------------------ '// Fehlerhandling einschalten, um VB-Meldung abzufangen '// ------------------------------------------------------------------------ On Error Resume Next FileExists = Dir(sFilePath) <> "" FileExists = FileExists And Err.Number = 0 '// ------------------------------------------------------------------------ '// Fehlerhandling wieder auschalten '// ------------------------------------------------------------------------ On Error GoTo 0 End Function
You need to login to post a comment.
