Posted By

qrist0ph on 05/19/08


Tagged

excel vba


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

qrist0ph


Excel Plain Text Export


 / Published in: Visual Basic
 

under Tools-References add "Microsoft Visual Basic for Applications Extensibility 5.3" as a reference

  1. ' under Tools-References add "Microsoft Visual Basic for Applications Extensibility 5.3" as a reference
  2. Sub ExportAllVBA()
  3.  
  4. Dim VBComp As VBIDE.VBComponent
  5. Dim Sfx As String
  6. For Each VBComp In ActiveWorkbook.VBProject.VBComponents
  7. Select Case VBComp.Type
  8. Case vbext_ct_ClassModule, vbext_ct_Document
  9. Sfx = ".cls"
  10. Case vbext_ct_MSForm
  11. Sfx = ".frm"
  12. Case vbext_ct_StdModule
  13. Sfx = ".bas"
  14. Case Else
  15. Sfx = ""
  16. End Select
  17. If Sfx <> "" Then
  18. VBComp.Export _
  19. fileName:=ActiveWorkbook.path & "\" & VBComp.name & Sfx
  20. End If
  21. Next VBComp
  22. End Sub
  23.  
  24. Public Function FileExists(sFilePath As String) As Boolean
  25.  
  26. If Trim(sFilePath) = "" Then Exit Function
  27. If Right(sFilePath, 1) = "\" Then Exit Function
  28. '// ------------------------------------------------------------------------
  29. '// Fehlerhandling einschalten, um VB-Meldung abzufangen
  30. '// ------------------------------------------------------------------------
  31. On Error Resume Next
  32. FileExists = Dir(sFilePath) <> ""
  33. FileExists = FileExists And Err.Number = 0
  34. '// ------------------------------------------------------------------------
  35. '// Fehlerhandling wieder auschalten
  36. '// ------------------------------------------------------------------------
  37. On Error GoTo 0
  38.  
  39. End Function

Report this snippet  

You need to login to post a comment.