Monthly Archives: December 2019

How to Export Your VBA Macros for Storage in a GIT/SVN Repository

This shows a quick workflow I use to handle VBA Macros so that they are diffed properly in a GIT/SVN repository.

Here is the example workbook.

Option Explicit
 Sub SaveCodeModules()
 'This code Exports all VBA modules
 Dim i As Integer
 Dim sName As String
 With ThisWorkbook.VBProject
     For i% = 1 To .VBComponents.Count
             sName = .VBComponents(i).CodeModule.Name
             .VBComponents(i).Export ThisWorkbook.Path & "\" & sName$ & ".vb"
     Next i
 End With
 End Sub