I wrote a build system for Excel that imports VBA code from source files (which can then be imported into the source control, various, etc.). It works by creating a new Excel file that contains the imported code, so it may not work in your case.
The assembly macro is as follows: I save it in the Build.xls file:
Sub Build() Dim path As String path = "excelfiles" Dim vbaProject As VBIDE.VBProject Set vbaProject = ThisWorkbook.VBProject ChDir "C:\Excel" ' Below are the files that are imported vbaProject.VBComponents.Import (path & "\something.frm") vbaProject.VBComponents.Import (path & "\somethingelse.frm") Application.DisplayAlerts = False ActiveWorkbook.SaveAs "Output.xls" Application.DisplayAlerts = True Application.Quit End Sub
Now, VBIDE stuff means you need to import a link called "Microsoft Visual Basic for Application Extensibility 5.3", I think.
Of course, you still have a problem with having to run Excel to build. This can be fixed with a small VB script:
currentPath = CreateObject("Scripting.FileSystemObject") _ .GetAbsolutePathName(".") filePath = currentPath & "\" & "Build.xls" Dim objXL Set objXL = CreateObject("Excel.Application") With objXL .Workbooks.Open(filePath) .Application.Run "Build.Build" End With Set objXL = Nothing
Running the above script should run the assembly Excel file, which displays the final sheet. You probably need to change some things to make them movable on the file system. Hope this helps!
Jonas
source share