My VB 6 program code is referring to 14.0 object library, it is compiled and executed..working fine with the new code (accessing 14.0 libraries).
In my development
The problem is that you are using Early Binding. You have to use Late Binding.
In Early Binding, you set a reference to the Excel Object xx.xx Library where as in late Binding you do not.
Here is an example of both
Early Binding
Sub EarlyBindingEx()
Dim oXLApp As Excel.Application
Dim oXLWb As Excel.Workbook
Dim oXLWs As Excel.Worksheet
'~~> Establish an EXCEL application object
On Error Resume Next
Set oXLApp = GetObject(, "Excel.Application")
'~~> If not found then create new instance
If Err.Number <> 0 Then
Set oXLApp = New Excel.Application
End If
Err.Clear
On Error GoTo 0
'~~> Show Excel
oXLApp.Visible = True
'~~> Open files
Set oXLWb = oXLApp.Workbooks.Open("C:\Sample.xlsx")
'~~> Set the relevant worksheet
Set oXLWs = oXLWb.Sheets(1)
'
'~~> Rest of your code
'
End Sub
Late Binding
Sub LateBindingEx()
Dim oXLApp As Object
Dim oXLWb As Object, oXLWs As Object
'~~> Establish an EXCEL application object
On Error Resume Next
Set oXLApp = GetObject(, "Excel.Application")
'~~> If not found then create new instance
If Err.Number <> 0 Then
Set oXLApp = CreateObject("Excel.Application")
End If
Err.Clear
On Error GoTo 0
'~~> Show Excel
oXLApp.Visible = True
'~~> Open files
Set oXLWb = oXLApp.Workbooks.Open("C:\Sample.xlsx")
'~~> Set the relevant worksheet
Set oXLWs = oXLWb.Sheets(1)
'
'~~> Rest of your code
'
End Sub
HERE is an MSDN link regarding Early Binding Vs Late Binding.