Solved

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

Posted on 2014-12-12
4
295 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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 how to use a scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 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

14 Experts available now in Live!

Get 1:1 Help Now