In How to update modules automatically in VBA I showed how you could get code from github into VBA and set up a kind of .require approach to which classes, modules and references are needed. Let’s go through a step by step example, using the Automatic documentation procedures and adding them to a workbook.
Another way to do this would be to create an add-in, but here’s how I prefer to do it – this way you can update library code from this site online automatically from gists on github.
Here’s a post from the Excel Liberation blog with an even simpler example
Prepare your workbook.
Either create a new one, or use your existing workbook that you want to include the code in. Remember to trust access to the VBA project object model in the trust center. This is because we are going to automatically insert code into your workbook.
Add gistThat bootstrap to your workbookThis gets in the code needed to modify your workbook automatically. You can get that here, Just paste it in to a new module, by convention called gistThat_
Bring in required modules
Public Function gtExampleLoad()
' this is an example of how you would load your VBE with a particular manifest
' you could set the 2nd parameter to overrride conflict checking the first time used-
' we are going to need cDataSet and cjobject stuff as well
gtDoit "3414394", True
' this one loads the class serializer
gtDoit "5028829", True
A note about virus false positives
- remove the gistthat module. You can always get it again here
- Turn back off trust to the VBA object model
- Run a virus scan on your workbook to reassure yourself you have followed these steps and not picked up any malware.