Add reference to Outlook library programmatically

  • Thread starter Thread starter Hiran
  • Start date Start date
H

Hiran

Hi,
Can someone tell me how to programmatically add a reference to a
library (Outlook, in my case) ?

Thanks,
Hiran
 
Try something like

Sub AddOutlookRef()
' reference current installed version of Outlook
On Error Resume Next 'ignore if already set
ThisWorkbook.VBProject.References.AddFromGuid _
GUID:="{00062FFF-0000-0000-C000-000000000046}", _
major:=0, Minor:=0
End Sub

You can add a reference to any file if you know the file name:

Sub AAA()
ThisWorkbook.VBProject.References.AddFromFile _
Filename:="C:\Path\FileName.ext"
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Chip,
I'm now trying to use this to add the ADO2.8 library (msado 15.dll)
and I get Run-time error '48' 'Error in loading DLL'.
What am I missing?
Thanks,
Hiran
 
Back
Top