Last Update: 2020 - 03 - 02
The Microsoft TreeView Control in 64bit Access
by Philipp Stiefel, originally published April 22 2020, last updated April 22 2020
Quite often one of the major problems with the migration to the 64bit-Edition of Microsoft Access is the Microsoft TreeView Control included in the Microsoft Windows Common Controls library. For a very long time this control was not available for 64bit.
This text is written with the TreeView control in close focus. But all the information here also applies to the other Common Controls, like the ListView, ImageList, and ImageCombo.
Prologue – (Un)Availability of the 64bit TreeView
In the early days of 64bit Office/Access there was increased confusion about this topic because apparently Microsoft included the Common Controls in the 64bit installation, but that were the 32bit Common Controls, which did not work in 64bit applications.
After years of countless support request and complaints, Microsoft finally decided to release a 64bit edition of the Microsoft Common Controls particularly for the use with Microsoft Office. This was released in the Update 1707 of July 27 2017 (Build 8326.2058).
Quote of the relevant info:
Office suite: Non-security updates
Add 64-bit support for mscomctl.ocx, allowing users working in 64-bit versions of Office to create, edit, and open macro files containing the Common Controls.
As there still is ongoing confusion on how to install and use the 64bit Edition of the Microsoft Common Controls, I decided to investigate the issues and write down my findings.
No 64bit TreeView with Access 2013 (and 2010)
I started my investigation with an installation of Microsoft Access 2013 64bit in Windows 8.1 (64bit). I’m very certain that the operating system is not relevant in this context and it will not matter whether this is done on Windows 7, 8 or 10.
With a default installation of Microsoft Access 2013 64bit there is neither a MSCOMCTL.OCX file in C:\WINDOWS\SysWOW64\ (this is the system directory of the 32bit subsystem!) nor in C:\Windows\System32 (the default 64bit system directory). If I try to insert an ActiveX Control into an Access form there is no Microsoft TreeView Control available in the list of installed ActiveX Controls.
The 64bit TreeView with Access 365 (and 2019)
Then I installed the 64bit Edition of Microsoft 365 Click-to-Run (C2R). At the time of writing, I got the Version 2003 of Access 2016/365. Installing this did not make any difference regarding the MSCOMCTL.OCX file in the Windows system directories mentioned above.
We must be aware of the fact that the C2R-Editions of Office are installed into a semi-virtualized environment (sandbox). For a 64bit Office installation, all files that are not immediately a part of Office will not be installed in the usual, global system directories but in the directory C:\Program Files\Microsoft Office\root\vfs (vfs = Virtual File System). The System subdirectory in the above directory now contains our desperately needed MSCOMCTL.OCX file.
After starting my newly installed Access 2016 and creating a new form, I’m immediately able to insert a TreeView Control into this form. The TreeView visually appears “normal”, displays the sample nodes and a small bit of test code I created, works also as expected, including the event handling.
Option Compare Database Option Explicit Private WithEvents m_MyTreeView As TreeView Private Property Get MyTreeView() As TreeView If m_MyTreeView Is Nothing Then Set m_MyTreeView = Me.ActiveXCtl0.Object End If Set MyTreeView = m_MyTreeView End Property Private Sub AddNodes_Click() Dim A1 As MSComctlLib.Node Set A1 = MyTreeView.Nodes.Add(, tvwChild, "A1", "A1") Dim i As Long For i = 1 To 9 MyTreeView.Nodes.Add "A1", tvwChild, "A1-" & i, "A1-" & i Next i A1.Expanded = True End Sub Private Sub m_MyTreeView_NodeClick(ByVal Node As MSComctlLib.Node) MsgBox "You clicked node: " & Node.Text End Sub
Redistribution to Access 2013, 2010 and early version of Access 2016
If I try the same in old Access 2013 installation, I still cannot insert the TreeView controls, as it is still missing from the list of ActiveX Controls. Opening the database, I created with Access 2016 earlier, and then opening the form with the TreeView resulted in in the error “There is no object in this control.”. – I was expecting this due to the Office 2016 sandbox.
The logical next step would be to copy the OCX file to the global System32 directory and register it there.
So, I copied the MSCOMCTL.OCX file from the Office virtual files system into the C:\Windows\System32 folder. I then ran cmd.exe as Administrator and executed
C:\Windows\System32\regsvr32 /i C:\Windows\System32\MSCOMCTL.OCX
Unfortunately, this failed with the error message “… the call to DllRegisterServer failed with error code 0x8004005.” – Well, this might have happened because there are some dependencies of MSComCtl.ocx that in the Office-VFS\System folder, which I did not copy.
Next, I tried to copy all the files from Office-VFS\System to a new folder and run regsvr32 for the OCX in that folder. – No luck, the error message quoted above persisted.
I’ve got no clue what the problem is here. Maybe I missed a step. If you see my mistake, please let me know!
Hacking the Redistribution
The normal and recommended way to register a DLL or OCX on any system is to use regsvr32.exe as I tried above. However, in the end for most ActiveX/COM controls and components it boils down to adding some keys and values to the Windows Registry.
As a workaround to the dead-end with using regsvr32 to register the OCX, I started RegEdit and looked for the relevant Registry keys and values for the TreeView Control of my Office 365 C2R installation.
These are usually in the HKEY_CLASSES_ROOT branch of the Registry and are below the class name (“MSComctlLib.TreeCtrl”) and the class id (=CLSID) (“C74190B6-8589-11D1-B16A-00C0F0283628”) of the control or component. As the C2R-Office is in a sandbox these values are also not in their usual registry path but sandboxed below the path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY.
I then exported these two keys with all their subkeys to.reg text files. I then edited those files and replaced their registry path with the usual base path HKEY_CLASSES_ROOT. After that I merged the edited files with the registry again.
(Reminder: I previously copied the MSCOMCTL.OCX file to C:\Windows\System32\. This is the file these re-imported registry values are pointing to!)
Et voilà! After merging my edited files in the registry, the Microsoft TreeView Control shows up in the list of insertable ActiveX controls in Access 2013! I also quickly tested my small code fragment from above and it worked!
You can download the reg-script I used to add the registry settings for Access 2013. However, this is intended as an example only. You should not use it to register the TreeView on your computer. Rather export these registry settings from your own installation, to make sure you get the settings matching your version of the TreeView control.
What if we need to use one and the same database application file in Access 32bit as well as Access 64bit? – If is an accdb (not compiled to accde) you can usually work with one and the same file without a problem. (If you use the Windows API, you need to make sure your API declarations are 64bit compatible.)
What about the TreeView in this situation? If I create a form with a TreeView in Access 2016 64bit where the TreeView control is automatically available, I can open the very same database file with Access 32bit (tried Access 2016/365, Access 2013, and Access 2010) and it works right away.
However, if I try a form with a TreeView control that was created in Access 2013 after applying the above registry hack, I get an error message in Access 32bit (again: Access 2016/365, Access 2013, and Access 2010).
“The expression [AnyEvent] you entered as the event property setting produced the following error: There was an error loading an ActiveX control on one of your forms or reports.”
This usually indicates a problem with binary compatibility between different versions of a control. However, this cannot be the case here, otherwise it should not have worked with the Access-2016-created file.
I guess, I must have missed something in my redistribution hack above. – I’m not really affected by this problem, so I’m not investing more time into fixing this problem. But, again, please let me know if you know the solution to the issue.
The other way round, creating a form with TreeView control in Access 32bit and then using this form in Access 64bit worked without any problems in the default Access 2016/365 installation as well as in Access 2013 with the “hacked” TreeView installation.
Current versions of Access 2016/365 (and probably Access 2019 as well) have a fully compatible MsComCtl TreeView control, which works out of the box.
However, this control is not intended for redistribution on its own, neither technically nor legally. If you need to use it with an older version of Access, you can probably work around the technical limitations using an approach like mine. But this does not solve any potential legal issues. - I’m not aware of any redistribution license for the 64bit MsComCtl.ocx.
If you want to distribute an application using the MsTreeView to users which don’t have an Access version with the 64bit-TreeView, the best option is probably using the Access 365 Runtime, which is receiving updates and thus should also include the 64bit common controls. – Disclaimer: I have not tested the Access 365 Runtime yet.
© 1999 - 2019 by Philipp Stiefel - Privacy Policiy