Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do Late Binding?

Status
Not open for further replies.

GPM4663

Technical User
Aug 9, 2001
165
GB
Dear All,
I understand the concept of late binding when dealing with references in MS Office but I'm not sure whether I'm doing it correctly. I've been using the following code in Excel to make an "email" button work correctly and different people have differnt office versions etc. Here's part of the code in a select case statement:

--------
Case "11.0" 'Office 2003
With ActiveWorkbook.VBProject.References
.Remove ActiveWorkbook.VBProject.References("Microsoft Outlook 11.0 Object Library")
MyPath = Application.Path & "\msoutl.olb"
strReference = MyPath
.AddFromFile strReference
End With

---------

However, I've noticed I get "Subscript out of range" error on the .Remove part if the file already has the correct reference. I can get round it by saying "On Error Resume Next" but I'd really like to understand whats going on and how to correctly do this.

Many thanks in advance,

GPM
 
Check reference name (with ..References(i).Name). The reference name is the same as displayed in object browser (here "Outlook").

combo
 
Thanks Guys,
That's a big help and seems to be a lot less problematic that the way I was trying to do it.

Cheers,

GPM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top