Home » MS OfficeRSS

Access automation - 2010 and 2007

I am attempting to write a single small application that automates Access. I need to be able to automate both Access 2007 and 2010 - the ability to automate previous versions as well would be good, but for now these two are providing a sufficient challenge.

I have Office 2010 installed locally on my development box. If I reference the 'Microsoft Office 14.0 Access Database Engine Object Library' COM component, all is well on my development box but some computers running 2007 can't locate Microsoft.Office.Interop.Access version 14.0.0.0. If I drop the COM object reference and add references to version 14 of the needed interop assemblies the application works fine on my computer but not on any systems running Office 2007 (no surprises there - they use interop 12.0). If I reference the 12.0 assemblies the application no longer works on the office 2010 systems.

What am I doing wrong?

 

5 Answers Found

 

Answer 1

Can you reference both/all version of the assemblies?

Failing that, you may need to try the older-style approach using the Win32 API calls GetObject()/CreateObject() for "Access.Application" and when you succeed/fail to get object instances, you can interrogate the Access.Application object's .version method to see what version is opened.

Unfortunately, you will loose early binding and perhaps also intellisense that way...


Mark Burns, MCAD, MCP
Sr. Microsoft Access Analyst/Developer
Manager LinkedIn.Com community: Professional Microsoft Access Developers Network (PMADN)
 

Answer 2

It isn't possible to reference multiple version of the same assembly (at least Visual Studio 2010 won't let me do it).

As a test I switched to the .NET 4 Framework (since it doesn't use the PIAs) which seems to work universally. This isn't really an ideal solution since it will likely require a framework update for some of our clients. If anybody else has a suggestion that would work with the .NET 3.5 framework I would be delighted to hear it.

 

Answer 3

No, you can't reference multiple versions of an assembly.

In Classic VB, the approach would be to use Late Binding, however I don't think that's an option with managed code.

 

Answer 4

VB.Net supports late binding (though doing so thru/via interop is perhaps another issue).
 

Answer 5

No, you can't reference multiple versions of an assembly.

In Classic VB, the approach would be to use Late Binding, however I don't think that's an option with managed code.


Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/djsteele (no e-mails, please!)
Co-author Access Solutions — Tips, Tricks, and Secrets from Microsoft Access MVPs (ISBN 978-0-470-59168-0)

My understanding is that this is basically what is being done "under-the-hood" in .NET 4 - instead of using a PIA it's interrogating the COM object for the needed information. I would still much prefer something that will allow me to retain my sanity when maintaining this application while also not forcing an update to .NET 4.
 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter