How to use version control with VBA code?

前端 未结 4 784
故里飘歌
故里飘歌 2020-12-13 09:59

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 ho

相关标签:
4条回答
  • 2020-12-13 10:34

    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.

    0 讨论(0)
  • 2020-12-13 10:38

    Check out this answer on how to automatically extract all modules/forms/classes to text files. Which will make them more manageable in SVN.

    0 讨论(0)
  • 2020-12-13 10:40

    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.

    0 讨论(0)
  • 2020-12-13 10:41

    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:

    http://svnbook.red-bean.com/en/1.0/ch05s02.html

    0 讨论(0)
提交回复
热议问题