Source control of Excel VBA code modules

前端 未结 6 1622
忘了有多久
忘了有多久 2020-12-02 10:19

I\'d like to be able to source control my Excel spreadsheet\'s VBA modules (currently using Excel 2003 SP3) so that I can share and manage the code used by a bunch of differ

6条回答
  •  生来不讨喜
    2020-12-02 10:32

    I've been working on exactly this for months. I think I figured it out.

    If the VB Project is trying to remove a module containing something in the call stack, it delays the removal until the call stack pops the module being replaced.

    To avoid a module being in the call stack, launch your code with Application.OnTime

    Private Sub Workbook_Open()
    
        'WAS: module_library (1)
    
        Application.OnTime (Now + TimeValue("00:00:01")), "load_library_kicker_firstiter"
    
    End Sub
    

    If you are self-healing your code like I am, you'll also have to launch your code that overwrites the 'calling' code with that same strategy.

    I did not perform extensive testing yet, I am in total celebration mode, but this gets me extremely close to straightforward 99.9% self-healing code within a standalone .xls file without any other tricks

提交回复
热议问题