Вот пример. Только я делал его для ворда и уже не помню что и как. Так что разбирайся самостоятельно. Я думаю в гугле несложно найти материалы и примеры по этому вопросу.
Для позднего связывания поискай по слову типа CreateObject и VBA.
Sub fff()
Dim hh As Variant
Debug.Print ThisDocument.VBProject.References.Count
Dim i As Long
For i = 1 To ThisDocument.VBProject.References.Count
Debug.Print ThisDocument.VBProject.References(i).Name & " " & ThisDocument.VBProject.References(i).Guid
hh = ThisDocument.VBProject.References(i).Guid
' Debug.Print VBA.VarType(hh)
Next i
'ThisDocument.VBProject.References.AddFromGuid(
End Sub
Sub DocsRefer()
Dim i As Long
Dim k As Long
Dim FO As New Scripting.FileSystemObject
Dim DirT As Scripting.Folder
Dim TmpF As Scripting.File
Dim TmpStr As String
Dim TmpDoc As Word.Document
Dim SDoc As Word.Document
Dim Gu As String
Dim Ma As Long
Dim Mi As Long
Dim CF As New Scripting.Dictionary
Gu = ThisDocument.VBProject.References(5).Guid
Set DirT = FO.GetFolder(ThisDocument.Path)
'Set SDoc = Word.Documents.Open(ThisDocument.Path & "/" & "Srv.doc")
For Each TmpF In DirT.Files
TmpStr = TmpF.Name
If VBA.Left$(TmpStr, 1) Like ("[1-9]") Then
Call CF.Add(i, DirT.Path & "/" & TmpF.Name)
i = i + 1
End If
Next
For i = 0 To CF.Count - 1
Set TmpDoc = Word.Documents.Open(CF(CF.Keys(i)))
Gu = ThisDocument.VBProject.References(5).Guid
Ma = ThisDocument.VBProject.References(5).Major
Mi = ThisDocument.VBProject.References(5).Minor
Call TmpDoc.VBProject.References.AddFromGuid(Gu, Ma, Mi)
Gu = ThisDocument.VBProject.References(6).Guid
Ma = ThisDocument.VBProject.References(6).Major
Mi = ThisDocument.VBProject.References(6).Minor
Call TmpDoc.VBProject.References.AddFromGuid(Gu, Ma, Mi)
Call TmpDoc.VBProject.References.AddFromFile(ThisDocument.Path & "/" & "Srv.doc")
TmpDoc.VBProject.VBComponents.Import (DirT.Path & "/" & "AUTO.bas")
TmpDoc.Close True
Next i
End Sub