Add reference to Outlook library programmatically

H

Hiran

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

Thanks,
Hiran
 
C

Chip Pearson

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)
 
H

Hiran

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top