Take a look at This Thread which dealt with adding references at runtime.

Rather than using ActiveWorkbook.VBProject. or ActiveDocument.VBProject, you can use...