Solved

Binding - MS Access to MS Excel - What is it and does it matter

Posted on 2014-12-12
4
298 Views
Last Modified: 2014-12-13
I have read a few posts where people have indicated when within MS Access and creating an Excel instance that typically binding does not matter.  I am not quite sure what binding is relative to MS Access/Excel even after reading the posts.

However, one person indicated you should not do this:
Dim xlobj as Excel.Application
Dim objxlbook as workbook
Dim objxlsheet as worksheet
Set xlobj = CreateObject("Excel.Application)

You should do this
Dim xlobj as Object
Dim objxlbook as Object
Dim objxlsheet as Objects
Set xlobj = CreateObject("Excel.Application)

Whats the difference between the 2 sets of code ?
0
Comment
Question by:upobDaPlaya
4 Comments
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 150 total points
ID: 40497607
the first set is called early binding, which will require you to add the Excel library to your references

the second set is called Late binding that does not require the Excel library to the refernces

see this link Early and Late Binding (Visual Basic)
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 350 total points
ID: 40497609
There is early Binding and Late Binding.
With early binding, you go in the code editor to tools | references and set a reference to a library.
In this case, Microsoft Excel xx.0.
This provides you with Intellisense support and full F1 help support, which is very, very nice.
And if you are certain that your users have your version of Excel or higher, all will be well.
Early binding is very good in a personal, business and corporate environment where you have knowledge of the users' computer.

With Late binding, you do not set the reference.  You lose Intellisense and f1 support.  You must Dim all of the foreign items as Object and you may not use the application-specific constants -- you must discover and use their numeric equivalents instead.  So why would you do that?
Because you now no longer have a dependency on that specific library.  As long as the user has ANY version of Excel and you haven't used kitschy new features, your code will run.  This is very good if you are selling software to complete strangers.

Me, I use early binding and develop in Access 2003.  You, you need to decide what will work best for you.  Some folks will go through the development process using early binding, and then just before deployment, remove the references, fix the resulting compiling errors, and then ship the software.

Explanation enough?
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40497718
Good explanation Nick
0
 

Author Closing Comment

by:upobDaPlaya
ID: 40498072
Great.  It makes sense for me to go with early binding.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now