How to use version control with VBA code?
I am developing a VBA application which is quite large. I want to use SVN for that application developing.
How can I split my modules from the Excel document and how to upload my modules separately to source control?
Please help me.
4 Solutions collect form web for “How to use version control with VBA code?”
With file->export file you can export the individual classes.
That’s one way to split the modules out – temporarily or otherwise.
Once you’ve done that, you can then create an SVN repository. I won’t go into instructions for that as it’s all over the internet, but here’s a starting point:
Check out this excel addin https://github.com/hilkoc/vbaDeveloper .
It exports all your vba code automatically, as soon as you save your workbook. You can also easily import it again, when you open a workbook. It all work very nicely.
As a bonus, it comes with a code formatter that you can run within the vba editor, so you can format your code as you write.
Check out this answer on how to automatically extract all modules/forms/classes to text files. Which will make them more manageable in SVN.
I wrote a small tool to help with putting VBA code under version control, without requiring anything from Excel, or locking you into any specific version-control system. It can either extract modules from an Office file to a folder, or publish modules from a folder to an Office file. In either case it accesses the Office file directly, not through Excel. It’s available on GitHub:
Microsoft Office VBA code is usually held in binary format, making proper version control difficult. VBA Sync Tool synchronizes macros between a VBA-enabled file and a folder, enabling easy version control using Git, SVN, Mercurial, or any other VCS.
To start, select the Extract VBA from Office file option, then select the locations of your repository (or where you’d like to start one) and the Office file. The tool will compare the two locations and show all the differences:
If you want to extract everything (typical for setting up a repository), just click OK. If you want to be more selective, you can untick specific files (for example some form designs that you know haven’t changed) and then proceed. If you set up a diff tool (under File → Settings), you can double-click on a module to view its changes.
After a merge, follow the same procedure, but select the Publish VBA to Office file option. When you hit Apply or OK, the tool will write the combined code into the Office file.