xla export classes, modules and forms

  • Thread starter Thread starter greg
  • Start date Start date
G

greg

In a regular excel document I can export all of the code by the following:

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


If I go inside of my xla and run this,
I can only get the thisworkbook.
none of the forms, classes or modules get exported.

is there a way to export these in an xla?
 
Not tested...
Go into the ThisWorkbook properties of the addin and change IsAddin to False
Run your program
Go back and change IsAddin to True
 
Change this:
For Each VBComp In ActiveWorkbook.VBProject.VBComponents

to this:
For Each VBComp In ThisWorkbook.VBProject.VBComponents


RBS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top