ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   xla export classes, modules and forms (https://www.excelbanter.com/excel-programming/414562-xla-export-classes-modules-forms.html)

greg

xla export classes, modules and forms
 
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?




Gary Brown[_4_]

xla export classes, modules and forms
 
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

--
Hope this helps.
Thanks in advance for your feedback.
Gary Brown


"greg" wrote:

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?





RB Smissaert

xla export classes, modules and forms
 
Change this:
For Each VBComp In ActiveWorkbook.VBProject.VBComponents

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


RBS


"greg" wrote in message
...
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?






All times are GMT +1. The time now is 01:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com