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