• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 522
  • Last Modified:

Runtime MS access 2007 running acess app 2003 - missing or broken reference to excel.exe error

I have a runtime access 2007 licence, i installed on a laptop. I have then converted an access 2003 db to Access 2007. When i try to open up the database using the runtime licence, i get an error Missing or Broken reference to Excel.exe.

The user is running exel 2002.

Any ideas guys
2 Solutions
Access will not adjust references to prior versions for non-Access object libraries.

Either you replicate the user's config during your development or else you switch from early to late binding in your code, so that you don't set a reference at all.  Note that once you switch to late binding you will get no Intellisense on Excel objects and none of the standard Excel constants will be recognised.  So you will either need to use their numeric values instead or (better) set up your own constants with the names you have already used in your code.
See here for an example of late binding..
Further to what Peter has said, I have an easy technique for switching between early- and late-binding.  This gives me all the advantages of intellisense and syntax checking during development, and eliminates version problems on distribution.
The trick is to put a compiler constant at the top of your module:
#Const EarlyBinding = 1
Then, in your code, wherever you declare Excel (/Word/Outloook etc) objects, you use a construction like this:
#If EarlyBinding Then
Debug.Assert xlCenter = -4108
Debug.Assert xlHairline = 1
Dim oXL As Excel.Application
Dim oWkb As Excel.Workbook
Dim oSht As Excel.WorkSheet
Dim oRng As Excel.Range
Const xlCenter = -4108
Const xlHairline = 1
Dim oXL As Object
Dim oWkb As Object
Dim oSht As Object
Dim oRng As Object
#End If
In the #If EarlyBinding section, each object is declared as the actual object in the referenced object library, while in the #Else section, the save variables are declared "As Object".
Also, every Const declaration in the #Else section is mirrored by a Debug.Assert in the #If EarlyBinding section.  This ensures, during development, that you are using the correct values for all your constants.
When the time comes to deploy your app, simply remove the reference and change #Const EarlyBinding to 0.
welsh_markAuthor Commented:
Hi Im a bit lost, Im just trying to open the database in a runtime licence in access 2007 when ive converted an access 2003 to access 2007, when i open it i get the error, I havent tried to write any code etc.

so unsure what the earl;y or late binding is, forgive my ignorance im not a programmer just be handed it and told to get on with it.
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

If YOU did the conversion from Access 2003 to 2007 then you ARE the programmer :-)
You should be able to fix it by deleting the reference to "Microsoft Excel 11.0 Object Library" and adding one to  "Microsoft Excel 12.0 Object Library".
What we have been suggesting is a way to make your database run on any computer with Excel installed, no matter what the version.
Try reading the VB123 article and use my conditional compilation idea to make life even easier.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
<off topic>
Graham - that one is going in the ToolKit! Thanks for that, I use Early binding and then switch over all the time, and it never occured to me to use compiler directives.

</off topic>
welsh_markAuthor Commented:
Hi Graham,

Dont tell my boss im a programmer he will expect me to do all sorts of techie black magic then.
Im now going to show my complete ignorance, where do i put that code ( polite answers pls) :-).
Well, first you undo your belt ... only kidding! :-D
Somewhere in your code, probably in the function(s) that does stuff with Excel, there must be some declarations like:
     Dim <something> As Excel.<something>
That is where you put the #If EarlyBinding - just before the Dim ... As Excel.... lines.
Then, just after those Dim statements, put the #Else and #End If.  Between them, copy and paste all the lines from above, and change all the "As Excel....." to "As Object"
At the very top of your module, put the #Const declaration:
#Const EarlyBinding = 1
Remember to set the reference (Tools>References) to whatever version of the Excel object library is on your computer.
And, Scott: It's all yours - glad you find it useful :-)

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now