View Single Post
  #17   Report Post  
Posted to microsoft.public.excel.programming
Peter T[_7_] Peter T[_7_] is offline
external usenet poster
 
Posts: 162
Default Can't find project or library


"hbj" wrote in message
Keep in mind if your file is ever loaded on a system without the 2.8 it
will
fail again. Late Binding would usually avoid these problems.


"Late Binding/Early Binding. I'm sorry not understanding those methods."

The reference to the library in Tools/References "early" binds the the
library. It loads faster and gives all the intelisense and named constants,
useful while developing. Problems can occur when distributing the project if
the version of referenced object library is different. Hence develop with
the reference, distribute without the reference. Without the reference all
object references should be declared 'As Object', and any named constants
should be replaced with their intinsic values. The project can include code
that handles both methods, eg

In Project Properties, Conditional Compilation Arguments,
LateB = 0

#If LateB Then
' include ADODB constants used in the project
Public Const adLockReadOnly As Long = 1
#End If

Sub test()
#If LateB Then
Dim rsCon As Object
Dim rsData As Object
#Else
Dim rsCon As ADODB.Connection
Dim rsData As ADODB.Recordset
#End If

' code

#If LateB Then
Set rsCon = CreateObject("ADODB.Connection")
Set rsData = CreateObject("ADODB.Recordset")
#Else
Set rsCon = New ADODB.Connection
Set rsData = New ADODB.Recordset
#End If

' code

End Sub

Adapt the code as above for object variables and include any named constants
also as above.

Head all modules Option Explicit and do Debug/Compile, test the code

Then test as Late Binding: change the conditional constant to LateB = 1,
remove the ADO reference in tools/refs, again do Debug/Compile, test the
code.

In theory Early Binding is much faster, but in practice typically won't
notice any difference with Late Binding

Peter T