We Recommend

Visual Basic 2008 Programmer's Reference Visual Basic 2008 Programmer's Reference
Visual Basic Orcas Programmer's Reference is a language tutorial and a reference guide to the upcoming Orcas release of Visual Basic. The tutorial provides basic material suitable for beginners but also includes in-depth content for more advanced developers.


Posted By

qrist0ph on 05/19/08


Tagged

excel


Versions (?)


Who likes this?

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

Report this snippet 

You need to login to post a comment.