Sub AddRuntimeLibrary()
Const imgFileName = "PrintIcon"
On Error Resume Next
'change this to your reference file C:\ ???
Application.VBE.ActiveVBProject.References.AddFromFile "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL"
'change the following to the GUID number that is shown on your sheet
Const GUIDRef = "{000204EF-0000-0000-C000-000000000046}"
Set PrntIcon = Application.CommandBars.FindControl(ID:=4)
On Error Resume Next 'Ignore Error If Reference Already Established
'change the following 5, 3 to the GUID number that is shown on your sheet
ThisWorkbook.VBProject.References.AddFromGuid GUIDRef, 4, 0
On Error Resume Next
'change this to your reference file C:\ ???
Application.VBE.ActiveVBProject.References.AddFromFile "C:\Program Files\Microsoft Office\Office\EXCEL9.OLB"
'change the following to the GUID number that is shown on your sheet
Const GUIDRef = "{00020813-0000-0000-C000-000000000046}"
Set PrntIcon = Application.CommandBars.FindControl(ID:=4)
On Error Resume Next 'Ignore Error If Reference Already Established
'change the following 5, 3 to the GUID number that is shown on your sheet
ThisWorkbook.VBProject.References.AddFromGuid GUIDRef, 1, 3
On Error Resume Next
'change this to your reference file C:\ ???
Application.VBE.ActiveVBProject.References.AddFromFile "C:\WINDOWS\system32\stdole2.tlb"
Const imgFileName = "PrintIcon"
'change the following to the GUID number that is shown on your sheet
Const GUIDRef = "{00020430-0000-0000-C000-000000000046}"
Set PrntIcon = Application.CommandBars.FindControl(ID:=4)
On Error Resume Next 'Ignore Error If Reference Already Established
'change the following 5, 3 to the GUID number that is shown on your sheet
ThisWorkbook.VBProject.References.AddFromGuid GUIDRef, 2, 0
On Error Resume Next
'change this to your reference file C:\ ???
Application.VBE.ActiveVBProject.References.AddFromFile "C:\Program Files\Microsoft Office\Office\MSO9.DLL"
Const imgFileName = "PrintIcon"
'change the following to the GUID number that is shown on your sheet
Const GUIDRef = "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}"
Set PrntIcon = Application.CommandBars.FindControl(ID:=4)
On Error Resume Next 'Ignore Error If Reference Already Established
'change the following 5, 3 to the GUID number that is shown on your sheet
ThisWorkbook.VBProject.References.AddFromGuid GUIDRef, 2, 1
On Error Resume Next
'change this to your reference file C:\ ???
Application.VBE.ActiveVBProject.References.AddFromFile "C:\WINDOWS\system32\FM20.DLL"
Const imgFileName = "PrintIcon"
'change the following to the GUID number that is shown on your sheet
Const GUIDRef = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}"
Set PrntIcon = Application.CommandBars.FindControl(ID:=4)
On Error Resume Next 'Ignore Error If Reference Already Established
'change the following 5, 3 to the GUID number that is shown on your sheet
ThisWorkbook.VBProject.References.AddFromGuid GUIDRef, 2, 0
On Error Resume Next
'change this to your reference file C:\ ???
Application.VBE.ActiveVBProject.References.AddFromFile "C:\Program Files\Microsoft Office\Office\MSACC9.OLB"
Const imgFileName = "PrintIcon"
'change the following to the GUID number that is shown on your sheet
Const GUIDRef = "{4AFFC9A0-5F99-101B-AF4E-00AA003F0F07}"
Set PrntIcon = Application.CommandBars.FindControl(ID:=4)
On Error Resume Next 'Ignore Error If Reference Already Established
'change the following 5, 3 to the GUID number that is shown on your sheet
ThisWorkbook.VBProject.References.AddFromGuid GUIDRef, 9, 0
On Error Resume Next
'change this to your reference file C:\ ???
Application.VBE.ActiveVBProject.References.AddFromFile "C:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll"
Const imgFileName = "PrintIcon"
'change the following to the GUID number that is shown on your sheet
Const GUIDRef = "{00025E01-0000-0000-C000-000000000046}"
Set PrntIcon = Application.CommandBars.FindControl(ID:=4)
On Error Resume Next 'Ignore Error If Reference Already Established
'change the following 5, 3 to the GUID number that is shown on your sheet
ThisWorkbook.VBProject.References.AddFromGuid GUIDRef, 5, 0
On Error Resume Next
'change this to your reference file C:\ ???
Application.VBE.ActiveVBProject.References.AddFromFile "C:\Program Files\Microsoft Office\Office12\MSWORD.OLB"
Const imgFileName = "PrintIcon"
'change the following to the GUID number that is shown on your sheet
Const GUIDRef = "{00020905-0000-0000-C000-000000000046}"
Set PrntIcon = Application.CommandBars.FindControl(ID:=4)
On Error Resume Next 'Ignore Error If Reference Already Established
'change the following 5, 3 to the GUID number that is shown on your sheet
ThisWorkbook.VBProject.References.AddFromGuid GUIDRef, 8, 4
On Error Resume Next
'change this to your reference file C:\ ???
Application.VBE.ActiveVBProject.References.AddFromFile "C:\WINDOWS\system32\scrrun.dll"
Const imgFileName = "PrintIcon"
'change the following to the GUID number that is shown on your sheet
Const GUIDRef = "{420B2830-E718-11CF-893D-00A0C9054228}"
Set PrntIcon = Application.CommandBars.FindControl(ID:=4)
On Error Resume Next 'Ignore Error If Reference Already Established
'change the following 5, 3 to the GUID number that is shown on your sheet
ThisWorkbook.VBProject.References.AddFromGuid GUIDRef, 1, 0
On Error Resume Next
'change this to your reference file C:\ ???
Application.VBE.ActiveVBProject.References.AddFromFile "C:\Program Files\PDFCreator\PDFCreator.exe"
Const imgFileName = "PrintIcon"
'change the following to the GUID number that is shown on your sheet
Const GUIDRef = "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613}"
Set PrntIcon = Application.CommandBars.FindControl(ID:=4)
On Error Resume Next 'Ignore Error If Reference Already Established
'change the following 5, 3 to the GUID number that is shown on your sheet
ThisWorkbook.VBProject.References.AddFromGuid GUIDRef, 7, 1