Share via


How to get Access 16.0 Object Library

Question

Monday, January 15, 2018 9:40 AM

I have a project with reference to the Access Object Library for Office 2007.

Recently we were forced to upgrade to Office365. With this came Office 2016 (including MS Access). Once installed, Visual Studio can no longer find any Access Object Library anymore, and my code won't run.

I found one forum post suggesting I run the Office 2016 installer and check that all necessary bits are installed, but the installer that comes with Office365 apparently is an all-or-nothing type of deal, that can only install or uninstall everything.

How / where can I get Access 16.0 Object Library?

All replies (17)

Tuesday, January 16, 2018 1:08 PM âś…Answered | 1 vote

Hi,

  1. Open Visual Studio Community 2015 
    version 14.0.25431.01
  2. New Project
  3. Templates > Visual Basic > Windows > Windows Forms Application
  4. Add button to form
  5. Open Project properties > References
  6. Add
  7. Look for Microsoft.Office.Interop.Access (any version)
  8. Reference is not in the list
  9. Look for Microsoft Access xx.x Object library
  10. Reference is not in the list
  11. No need to proceed further

Regards,

Johan

The Microsoft Access x.x library should be visible in the list when the Add Reference COM tab is selected. If it is not visible, then it sounds like you have an installation issue with Office.

The Office PIA is installed through the Visual Studio installation configuration. I believe it's the Office/SharePoint Development option. 

Paul ~~~~ Microsoft MVP (Visual Basic)


Monday, January 15, 2018 7:02 PM | 1 vote

Can you use late binding to create an instance of the application object? If you can then check the Version property to see which version you have installed.

Dim applicationObject As ObjectSet applicationObject = CreateObject("Access.Application")
MsgBox applicationObject.Version

'or if .NET

applicationObject = CreateObject("Access.Application")
MsgBox(applicationObject.Version)

Paul ~~~~ Microsoft MVP (Visual Basic)


Tuesday, January 16, 2018 5:46 AM | 1 vote

Hi Johan_Hakkesteegt,

i am also using Office 365.

You can go to Visual Studio.

Open your project.

Right click on References and click Add Reference.

you will find 15.0 version of Access interop. which you can try to reference and check whether it solve your issue or not.

if your issue is persist then let us know which version of Visual Studio you are using.

what kind of project you are developing and if possible then you can try to post sample code to reproduce the issue.

Regards

Deepak

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Tuesday, January 16, 2018 7:37 AM

Hi Paul,

Thanks, using .NET, it throws a "Cannot create ActiveX component" error on this line: applicationObject = CreateObject("Access.Application")

Regards,

Johan


Tuesday, January 16, 2018 7:40 AM

Hi Deepak,

Thanks, using VS 2015, I do not see this reference. Neither under Assemblies, nor under COM. Is it possible to get the needed driver separately somehow, or to get it "reinstated"?

Regards,

Johan


Tuesday, January 16, 2018 7:43 AM

Hi Johan_Hakkesteegt,

It is better , if you post a sample code that generates an error.

We will try to make a test with it.

Also try to provide detailed information about your project type , VS version etc.

Did you try to check the Access References as i mentioned in my previous post?

Generally Office PIA get installed when you install the Office.

So it should be available in references.

Let us know about your testing result.

So that we will try to provide further suggestions , if needed.

Regards

Deepak

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Tuesday, January 16, 2018 8:59 AM

Hi Deepak,

I think we posted our replies at the same time :-)

So additional answers:

- I use Visual Studio 2012 and 2015. We are in the process of switching all applications to 2015, and the latest .NET

- A simplified example of the (VB.NET) code I use:

Dim oAccess As Access.Application
Dim x As Long
AccessExecutablePath = New FileInfo("C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE").FullName
x = Shell(AccessExecutablePath & " " & Chr(34) & DatabasePath & Chr(34) & "  /runtime", AppWinStyle.MinimizedNoFocus)
oAccess = New Access.Application
oAccess = GetObject(DatabasePath)
oAccess.PrintReport("Some_Report_Saved_In_MSACCESS")

- I have used this code in several windows applications, both x86 and x64 compiled.

- The reference should be available, but it isn't. Can I get it separately, or can we fix this issue somehow?

Regards,

Johan


Tuesday, January 16, 2018 9:09 AM | 1 vote

Hi Johan,

What is the project type did you use?

Can you open Access application to create a simple database manually?

For this new database, turn to VBA Editor window-> Tools->Reference-> Is there Microsoft Access 16.0 Object library in it?

Best Regards,

Tao Zhou

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Tuesday, January 16, 2018 9:40 AM

Hi Tao Zhou,

In the Access application / database, I can see the Microsoft Access 16.0 Object library, and also all the other Office libraries like Excel 16.0, Outlook 16.0 etc.

So apparently they did get installed. How do I get them to show up in Visual Studio?

Regards,

Johan


Tuesday, January 16, 2018 9:55 AM | 1 vote

Could you share us the detail steps you create this project in VS?

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Tuesday, January 16, 2018 11:32 AM

Hi,

  1. Open Visual Studio Community 2015 
    version 14.0.25431.01
  2. New Project
  3. Templates > Visual Basic > Windows > Windows Forms Application
  4. Add button to form
  5. Open Project properties > References
  6. Add
  7. Look for Microsoft.Office.Interop.Access (any version)
  8. Reference is not in the list
  9. Look for Microsoft Access xx.x Object library
  10. Reference is not in the list
  11. No need to proceed further

Regards,

Johan


Tuesday, January 16, 2018 2:45 PM

Hi Paul,

You were right, all it took was an online repair of Office, and the referenced showed up in Visual Studio.

Regards,

Johan


Thursday, May 24, 2018 8:52 PM

I am actually trying to do something similar, but the issue is I can not have Office installed on the server so I somehow need to use the object library and run an Excel Macro.

I used ace.12 and I am able to get the excel file and also get its sheet name with the code below:

But I cannot make the Access.Application work at all...Is there any thing I can download and add as a refrence and make it work without installing Office??

Please advise.


Thursday, May 24, 2018 8:53 PM

Public Sub Main()
        Dim fileToTest As String
        Dim tableToTest As String
        Dim connectionString As String
        Dim excelConnection As OleDbConnection
        Dim excelTables As DataTable
        Dim excelTable As DataRow
        Dim currentTable As String

        fileToTest = Dts.Variables("ExcelFile").Value.ToString
        tableToTest = Dts.Variables("ExcelTable").Value.ToString

        Dts.Variables("ExcelTableExists").Value = False
        If File.Exists(fileToTest) Then
            connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" &
        "Data Source=" & fileToTest &
        ";Extended Properties=Excel 8.0"
            excelConnection = New OleDbConnection(connectionString)
            excelConnection.Open()
            excelTables = excelConnection.GetSchema("Tables")
            For Each excelTable In excelTables.Rows
                currentTable = excelTable.Item("TABLE_NAME").ToString
                MessageBox.Show(currentTable)
                If currentTable = tableToTest Then
                    Dts.Variables("ExcelTableExists").Value = True
                End If
            Next
        End If

        Dts.TaskResult = ScriptResults.Success
        ' Dts.TaskResult = ScriptResults.Success
    End Sub


Friday, May 25, 2018 12:54 AM

Hi ShayAz,

I think your issue is not similar.

In the original post user was using MS Office on local.

You are working without office on server side and want to use Excel and Access Object library.

It is not recommended to use Office interop on server side.

Considerations for server-side Automation of Office

Generally, We suggest developers to use Open XML as an alternative.

So you can also try to check it, Whether it helps you to solve your issue.

If then also you have any further question then I suggest you to create a new thread with detailed information about your issue.

We will try to provide further suggestions to solve the issue.

Regards

Deepak

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Friday, May 25, 2018 2:16 AM

Note sure why you need "fileInfo" class, but it don't matter.

However, you path name looks wrong. the x32 bit version of Access on a x64 bit machine will be:

"C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE"

So it not clear how your previous code worked, but "most" machines today are x64 bits, and the vast majority of office installs are x32. You thus have to use the

"C:\Program Files (x86)

as a path name to get to the msaccess.exe file.

I have seen a number of "wonkey" setups where the IT folks did not know better and they forced the x32 install into the x64 bit folder (Program Files). Windows does not FORCE this install location, but is only a general accepted location that "most installers respect. (in other words, you can install x32 programs into what is supposed to be reserved for x64 (c:\Program files).

And, it turns out you can also install x64 bit programs into what is supposed to be reserved for x32 (program Files (x86).

So while I seen some IT folks install always and everything into the x64 bit program file, including a mix of x32, and x64 programs (which is allowed), it likely that Access is x32, and it likely that it is installed in c:Program Files (x86).

The reg key location to where msaccess.exe is installed can be found here:

HKEY_LOCAL_MACHINE,

'SOFTWARE\Microsoft\Office\16.0\Access\InstallRoot\,

'path'

Regards,

Albert D. Kallal (Access MVP, 2003-2017)

Edmonton, Alberta Canada


Wednesday, May 29, 2019 4:03 PM

buen amigo:

En office 365 la referencia "Microsoft Office 16 Object Library" En la ventana de Referencias aparece como "Office". solo es seleccionarla y se carga la libreria . 

Saludos