I have this code:
Which results in this:
But I want this:
How?
Code:
Sub CreateImportModule()
Dim CodeMod As VBIDE.CodeModule
Dim x As Integer: x = 2
Dim vArrModules() As Variant
Dim VBProj As VBIDE.VBProject
Dim VBCompModule As VBIDE.VBComponent
Dim VBCompAddModule As VBIDE.VBComponent
Dim y As Integer
Set VBProj = ActiveWorkbook.VBProject
For Each VBCompModule In VBProj.VBComponents
ReDim Preserve vArrModules(y)
vArrModules(y) = Chr(34) & VBCompModule.Name & ".bas" & Chr(34) & ", "
y = y + 1
Next VBCompModule
Set VBCompModule = VBProj.VBComponents.Add(vbext_ct_StdModule)
VBCompModule.Name = Replace(ActiveWorkbook.Name, ".xlsm", "") & "ImportModule"
Set VBCompModule = VBProj.VBComponents(Replace(ActiveWorkbook.Name, ".xlsm", "") & "ImportModule")
Set CodeMod = VBCompModule.CodeModule
With CodeMod
.InsertLines x, " Dim strModuleName(): strModuleName = Array(" & Left(Join(vArrModules, ""), Len(Join(vArrModules, "")) - 2) & ")"
End With
End Sub
Code:
Dim strModuleName(): strModuleName = Array("ThisWorkbook.bas", "Sheet1.bas", "Module1.bas", "Module2.bas", "Module3.bas")
Code:
Dim strModuleName(): strModuleName = Array("ThisWorkbook.bas", _
"Sheet1.bas", _
"Module1.bas", _
"Module2.bas", _
"Module3.bas")