Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put Excel VBA into git

Tags:

I've inherited some VBA in Excel and want to put it into git. As it stands, git sees it as binary and doesn't want to do file change deltas but duplicate the whole file.

I want to break the individual macros out into files to put them into git. Is there a standard way to do this?

like image 531
KeepCalmAndCarryOn Avatar asked Mar 15 '16 23:03

KeepCalmAndCarryOn


People also ask

How do I push VBA code to Github?

In The VBA Editor Add modules for each macro (Menu Insert/Module) copy each macros code into a module and save as a text file with control + E. Save into your git folder and use the normal git procedures to commit any changes. When you change the vba code re save (control+E) the module and update git as normal.

Does git work with Excel files?

The extension makes git diff work for Excel VBA (xls, xlt, xla, xlam, xlsx, xlsm, xlsb, xltx, xltm). Git XL does not require Excel as it works directly on the workbook file. With Git XL installed, Git can diff Excel VBA just like any other source code file.


2 Answers

If you use Rubberduck VBA, after clicking

Ready Button

You can use the file menu to "Export Active Project", which exports the form binaries and the code as BAS objects, which are just plain text. Then you can commit to git.

Tools -> Export Active Project

like image 73
Cody G Avatar answered Oct 14 '22 02:10

Cody G


You should be able to export modules as text to a git folder then commit as follows.

In The VBA Editor Add modules for each macro (Menu Insert/Module) copy each macros code into a module and save as a text file with control + E. Save into your git folder and use the normal git procedures to commit any changes.

When you change the vba code re save (control+E) the module and update git as normal.

like image 24
automate Avatar answered Oct 14 '22 03:10

automate