{"id":13706436,"url":"https://github.com/StandishMan25/VBA-Module-Bundler","last_synced_at":"2025-05-05T20:31:18.626Z","repository":{"id":130791964,"uuid":"88509757","full_name":"StandishMan25/VBA-Module-Bundler","owner":"StandishMan25","description":"Imports source's referenced xlam/xlsm file's classes and modules and bundles it into one singular project.","archived":false,"fork":false,"pushed_at":"2017-04-17T23:23:31.000Z","size":139,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-03T22:17:23.493Z","etag":null,"topics":["csharp","csharp-library","vba","vba-library"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StandishMan25.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-17T13:18:07.000Z","updated_at":"2023-08-13T17:19:42.000Z","dependencies_parsed_at":"2023-04-04T23:21:51.143Z","dependency_job_id":null,"html_url":"https://github.com/StandishMan25/VBA-Module-Bundler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StandishMan25%2FVBA-Module-Bundler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StandishMan25%2FVBA-Module-Bundler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StandishMan25%2FVBA-Module-Bundler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StandishMan25%2FVBA-Module-Bundler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StandishMan25","download_url":"https://codeload.github.com/StandishMan25/VBA-Module-Bundler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224465839,"owners_count":17315883,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","csharp-library","vba","vba-library"],"created_at":"2024-08-02T22:00:56.283Z","updated_at":"2024-11-13T14:31:03.850Z","avatar_url":"https://github.com/StandishMan25.png","language":"C#","funding_links":[],"categories":["C# #"],"sub_categories":[],"readme":"# VBA Module Bundler\nImports source's referenced file's classes and modules and bundles it into one singular project.\n\n##  Required References for Building\nThis project uses the following references:\n* [EPPlus](https://github.com/pruiz/EPPlus/tree/master/EPPlus) \n* [System.ValueTuple](https://www.nuget.org/packages/System.ValueTuple/) library from Microsoft\n* Visual Studio 2017 for C# 7 syntax.\n\n## Usage\n### Command Line Parameters using the Test Console\nThere are 5 properties exposed from the Bundler API, _italic_ are optional:\n* __Source__: The path to the file you wish to pull all references from and merge into.\n* __Target__: The path to the resulting file after the merge is complete.\n* _Recurse_: If true, will go down the chain of references until none are left, bubbling the merges.\n* _Use-Source_: If true, will default to using the source modules on any conflict. If false, will prompt or throw exception.\n* _Only-Merge-Used_: If true, will search through the code and determine which modules are required for functionality, else will include everything.\n* _Help_: Displays a help message similar to this list. Can be invoked with ?, h, hlp, help.\n\nYou pass arguments with a '/' in front of the parameter name, and a space between the name and value, like so:\n`C:\\\u003eVbaModuleBunder.exe /source \"C:\\some\\path\\to\\file.xlam\" /target \"C:\\some\\path\\to\\anotherFile.xlsm\" /recurse true /use-source true /only-merge-used true`\n\n### Other\nAdd a reference to the library in the target application and follow the below format. \n\n    var bundler = new Bundler(new Logger());\n\n    bundler.TryGetFileInfo(source, out var sourceInfo);\n    bundler.TryGetExcelPackage(sourceInfo, out var package);\n    bundler.TryBundleProjects(ref package);\n\n`TryBundleProjects` is the simple way, but if desired, you could replicate the private method and inject your own logic if desired.\n\n\tproject = package.Workbook.VbaProject;\n\tvar references = this.GetReferences(package.Workbook.VbaProject);\n\n\t/*\t\n\t*\tIterate through the references of the dependent Excel projects, recursing if desired.\n\t*\tThis merges dependent modules into the target project, and adds system libraries as well,\n\t*\tto assist in preventing invalid projects on load.\n\t*/\n    foreach (var reference in new List\u003cExcelVbaReference\u003e(references.Excel))\n\t{\n\t\tvar path = this.GetReferencePath(reference);\n\t\tthis.TryGetFileInfo(path, out var referenceInfo);\n\t\tthis.TryGetExcelPackage(referenceInfo, out var referencePackage);\n\t\tvar referenceProject = referencePackage.Workbook.VbaProject;\n\t\tvar referencedReferences = this.GetReferences(referenceProject);\n\n\t\tif (_recurseReferences \u0026\u0026 referencedReferences.Excel.Count() \u003e 0)\n\t\t{\n\t\t\tTryBundleProjects(ref referencePackage, ref referenceProject);\n\t\t}\n\t\tthis.TryMergeModules(referenceProject, project, out var modules);\n\t\tthis.TryMergeSystemReferences(ref project, referencedReferences.System);\n\t\tthis.TryAddToProject(ref project, modules);\n\t\tthis.TryRemoveReference(ref project, reference);\n\t}\n            \n## Caveats\n* EPPlus cannot transfer/create Designer Modules (UserForms)\n* EPPlus cannot save a file as an `xlam` file, thus no \"hidden\" libraries could be created from this. You could of course save this as an `xlsm` extension, then open and save as `xlam`.\n* Ribbon methods (customUI) appear to not function properly when merged.\n\n## Example\n`MVVM_Form` references `Interfaces` and `Immutable`. `Immutable` references `Interfaces` as well. Both `MVVM_Form` and `Immutable` are using the early binding technique for namespacing and readability.\n\n![Before](/Images/Before.png?raw=true \"VBA Project referencing xlam libraries\")\n\nAfter running, `MVVM_Form` is the only project open, and only the necessary modules and classes were \"imported\". All modules and classes can be imported by setting _Only-Merge-Used_ to false.\n\n![After](/Images/After.png?raw=true \"Single project with necessary references from dependencies\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStandishMan25%2FVBA-Module-Bundler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FStandishMan25%2FVBA-Module-Bundler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStandishMan25%2FVBA-Module-Bundler/lists"}