Consulting

Results 1 to 4 of 4

Thread: Exporting VBA Modules

  1. #1

    Exporting VBA Modules

    Every so often I go through my workbooks and export all the modules to a sete of "module save" folders. If there's been a lot of changes, I also delete all modules and then import them to compress them. It just occurred to me that I don't know if I'm exporting the "Workbook" modules (the ones with "Workbook_Open" etc) when I do that. Should I be exporting something from the Workbook level?
    I apparently did that at one time and created a ".cls" entry,
    but I have no idea what's in it.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You can just import it. It will import as a class module, then you can copy/paste the code into a sheet module or ThisWorkbook.

  3. #3
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Hi CD,

    The excel objects technically are class objects in VBAs eyes, which is why it is exporting them as .cls files. You can open them in notepad, the pertinent code is under the Attribute statements. If you wanted to export programatically, you could use:

    Sub cyberdude()
     Dim aComponent As Object, ExportPath As String
     ExportPath = "C:\backup\" 'ends in "\"
     For Each aComponent In ThisWorkbook.VBProject.VBComponents
      Select Case aComponent.Type
       Case 2, 100: aComponent.Export ExportPath & aComponent.Name & ".cls"
       Case 1: aComponent.Export ExportPath & aComponent.Name & ".bas"
       Case 3: aComponent.Export ExportPath & aComponent.Name & ".frm"
      End Select
     Next
    End Sub
    Matt

  4. #4
    Thanx for the ideas and code, Guys. That's what I wanted to know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •