Hello everybody
I`d like to know if the Microsoft Excel 11 Object Library, installed by Microsoft Office 2003, can be used on machines which might have another version of Microsoft Office installed.
Printable View
Hello everybody
I`d like to know if the Microsoft Excel 11 Object Library, installed by Microsoft Office 2003, can be used on machines which might have another version of Microsoft Office installed.
Moved from Classic VB forum.
If your early binding by adding the reference then you will incur issues with different class interfaces between different versions.
so what can I do? How can I late bind to the Excel Object Library?
You can late bind Excel by declaring the variable as an object and using createobject. You must however be aware that some functions may not be available in older versions of Excel..
You will also not have the intellisense associated with the early binding method.Code:Dim objEX As Object
Set objEX = CreateObject("Excel.Application")
ok. It worked. But, I still haven`t understood the difference with the code I used :
VB Code:
Set oApp = New Excel.Application Set oWB = oApp.Workbooks.Add oWB.Sheets(1).Cells(1, 1).CopyFromRecordset rsTmpMhxanhma oApp.Visible = True
Am I not creating space for the oApp object at runtime as well? Does it have to do with the fact that oApp has already been defined as an Excel Application object. Finally do I also need to late bind the Excel.Workbook object as well?
This link may help you with your Early/Late knowledge.
http://www.dicks-clicks.com/excel/ol...#Early_Binding
Here is my method, while you are writing the application, set a reference to the appropriate library:
Now delcare your variables:
VB Code:
DIm oApp as Excel.Application Set oApp = CreateObject("Excel.Application")
Since the reference is set, oApp. will bring up the intellisense use. When you are done wrting the code and testing, and ready to distibute your project:
Uncheck the reference and replace your Application specific variable types with Object:
VB Code:
DIm oApp as Object Set oApp = CreateObject("Excel.Application")
Make sure you Compile to catch any errors with the code. When doing automation, you may need to use the applications constants in place of some things becasuse Late Binding can't take care of everything. It is more reliable of a method than early if you don't know what version's of office will be using you project and that the version's may switch.
Hope this helps a bit.........