Got treeview working in Access 2013 again! :)

I while ago I made a post saying that I couldn’t get the treeview working in Access 2013. Mr Jan Karel Pieterse was kind enough to drop by and leave a remark saying that the treeview should work. So I decided to go back and give it a another try.

And this is where it did start to look a bit weird to me. My Windows 8 with Office 365 version of access 2013, apparantly doesn’t come with mscomctl.ocx installed. Now that in itself is ok, but the reason I actually never checked to see if it was installed is 2 fold:

MsComCtl.ocx have been on included on all installations I have worked on so far, from office 2000 to office 2010 in windows xp to windows 7.

Within Access one of the things I tried was removing the treeview control, and adding back a “new” one. The treeview control was available from the dropdown but apparantly the required file was missing? I don’t know to be honest, I don’t dabble much in such system files. But since I could select the treeview control from the “Insert ActiveX control”, I never thought to check if it was actually installed.

Anyway, if you are like me, you will poke and prod, trying different solutions, and when it finally works, you end up wondering which of the many cogwheels turned that actually had the desired effect, and whether it was just a single cogwheel or the combination of several. Either way, I will list what I did, without the knowledge of which item finally fixed it.

Copied MsComCtl.ocx from my Windows 7 computer with Office 2010. Placed in C:\Windows\SysWow64 folder, AND c:\Windows\System32 folder

Registered it.

Decompiled, and recompiled my Access application.

Deleted treeview control from form, and added a “new” treeview control.

With the above steps it seems to have worked, and I now have normal treeview operation. Most of these steps were actually done over several days, and initially my batch file for registering the activex control didn’t work (due to admin privileges)  but I didn’t notice that, and had actually given up.

 

Summary:

It is possible to use a treeview in Access2013, but you have to take some steps to distribute the activeX control, and have admin privileges to register it. So its certainly way more cumbersome now than earlier.

EDIT:

Please take note of Timc’s reply below, as it comes with some detailed and excellent instructions.

EDIT 2:

Please take note of the suggestion on reference fix found here:

http://www.utteraccess.com/forum/index.php?showtopic=2032428&pid=2564329&st=0&#entry2564329

 

Posted in Treeview
45 comments on “Got treeview working in Access 2013 again! :)
  1. Ben says:

    Good tip. Hopefully this article will catch the eye of anyone else who thinks it’s not possible.

    Does the problem you experienced only apply to Access 2013 with Windows 8? If you had a previous version of Windows, or had installed a previous version of Access on Windows 8, you should have the MsComCtl.ocx installed. Right??

    • TheSmileyCoder says:

      Hi Ben
      That is a good question. I believe that the ocx was distributed with either windows or office since XP came out.I know it was available on my “fresh” windows 7 pc with office 2010. As to whether it came as part of office or windows I can’t say.
      If one day I get a client where I need to make a installer for distributing the ocx and registering it, I will be sure to blog about it 🙂

  2. Ted says:

    I have exactly the same issues. My treeviews now only have 5 event properties in office 2013. I am testing out a application developed in windows 7 and Access 2010 and find that the treeview expand and collapse events, and drag and drop events do not exist in code any more. This is a brand new PC with Windows 8.1 and Office 2013 so no prior versions on it. There is an MSCOMCTL.OCX file but it is located at C:\Program Files\Microsoft Office 15\Root\VFS\SystemX86\ As it it it is useless. Why does Microsoft do this. Do they just enjoy making life hard for people. Why if it is there at all, could they not leave it alone so it exposed all its events as before. Can you imagine distributing a system to a client and asking them to un-register an OCX, replace it with an old copy, and re-register it and then go and replace it on every form where it is to be used. They will say you must be joking. Microsoft have ruined so many good aspects of Access in the last few upgrades. I guess they do not want developers to use it any more. They killed ADP now looks like ActiveX controls, what next?

    • Mark says:

      I agree Ted. It’s as if the programming lunatics are running the practical asylum. Why wouldn’t MS think there should be a native TreeView control. Why do they think that 3 colors is sufficient for Conditional formatting. For all their brains the folks at Microsoft aint giving us what we want but what they think we want.

  3. TheSmileyCoder says:

    Hi Ted
    I have not yet actively used treeviews in Access 2013, just tested a bit and fooled around. For what its worth I think its possible to automate some, if not all, of the required steps, although it will likely have to be run by a admin if the registry is locked down.

  4. David Lario says:

    Works like a charm. Thank you so much! I was pretty heart broken to see a valuable tool be no longer supported.

  5. Dàvide says:

    Ok it works! I simply copied MSCOMCTL.OCX from my Windows 7 computer with Office 2010 and placed it in C:\Windows\SysWOW64\ and C:\Windows\System32\ folders and registered it with “regsvr32 MSCOMCTL.OCX” without making other operations… Thanks!

  6. Jamie says:

    Just wanted to give you a massive thank you for this info. Truly, you saved me countless hours of headache.

  7. Davide says:

    No way. The events are still 5. Other suggestions?

  8. Hung Nguyen says:

    Hello, I am a High School teacher from Vietnam. Could you please have a few lines more specifically on how to register the mscomctl.ocx? Many thanks.

    • TheSmileyCoder says:

      Hello Sir
      I am not too experienced with the registry but this should work:
      Hopefully you have a PC around that already has the component installed, I believe any Windows 2000-Windows 7 PC with Office 2000-Office 2010 should come with it installed. You can copy the file from one of those PCs and place it into the appropriate folder (See below which folder to use)

      Click Start, type cmd.
      Right-click the cmd icon, and then click Run as Administrator.
      Depending on your operating system, type the either of the following commands, and then press Enter:
      For 64-bit Windows, type the following:
      Regsvr32 “C:\Windows\SysWOW64\MSCOMCTL.OCX”
      For 32-bit operating systems, type the following:
      Regsvr32 “C:\Windows\System32\MSCOMCTL.OCX”

      Hope that helps

  9. You can actually install these: They are available as a download from Microsoft as the Visual Basic 6.0 Common Controls, saves having to register and copy them manually. You can get stuck doing this with databases that were working previously too. If the reference to the common control .ocx file gets broken in the Access database it corrupts the binary portion of the existing controls on the forms. Copying, deleting and pasting a new copy of each affected control fixes that part. But you have to fix the reference first.

  10. timc512 says:

    Hmm… I know it’s a little late in the game, but since this page is a top result on google (if you search for mscomctl.ocx and office 2013) I’d like to offer up my fix for this same issue. Microsoft has released fixes for this with Office 2003, 2007, and 2010, but still nothing for 2013. I found this page while looking for their fix (again) unsuccessfully (again).

    The mscomctl.ocx file actually does exist in an Office install, it’s location has just moved from the system folders (system32 or syswow64) to:
    %programfiles%\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx

    Copying the file from an old machine and replacing the treeview works, of course, but if you don’t have an old copy of the file or you don’t want to go through the hassle of copying, replacing, and recompiling, then you can use this method, which involves simply creating and running a batch file, with instructions below.

    This batch file is adapted to work with Office 2013 from a Microsoft fix that is available for previous versions of Office. The problem is, those fixes won’t work on Office 2013. This fix works for all versions of Office from 2003 to 2013. For more information, go see the Microsoft support article here: https://support.microsoft.com/en-us/kb/2748410

    Here are the instructions to create and run the batch file. These are copied near verbatim from the Microsoft article, with the addition of the correct location of the Office 2013 version of mscomctl.ocx:

    ******************************************************************************
    1. Create a new text file and copy and paste the following to it:

    *** copy below here ***

    reg delete hkcr\typelib\{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}\2.0 /f

    if exist “%programfiles%\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx” goto 2013
    if exist %systemroot%\SysWOW64\cscript.exe goto 64
    %systemroot%\system32\regsvr32 /s /u mscomctl.ocx
    %systemroot%\system32\regsvr32 mscomctl.ocx
    exit

    :64
    %systemroot%\sysWOW64\regsvr32 /s /u mscomctl.ocx
    %systemroot%\sysWOW64\regsvr32 mscomctl.ocx
    exit

    :2013
    if exist %systemroot%\SysWOW64\cscript.exe goto 2013×64
    %systemroot%\system32\regsvr32 /s /u “%programfiles%\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx”
    %systemroot%\system32\regsvr32 “%programfiles%\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx”
    exit

    :2013×64
    %systemroot%\sysWOW64\regsvr32 /s /u “%programfiles%\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx”
    %systemroot%\sysWOW64\regsvr32 “%programfiles%\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx”
    exit

    *** copy above here ***

    2. Save the file.
    3. Change the file extension from .TXT to .BAT.
    4. Run the .BAT file by right-clicking on it and choosing ‘Run as Administrator’ (XP users can simply double-click to run the file).
    ********************************************************************************

    For a technical explanation of what each line does see the Microsoft support article, but here is the general idea:

    1. Deletes the old 2.0 typelib key from the registy (the correct version is 2.1). Sometimes this is not needed. Most of the time it is, and it doesn’t hurt anything to run.
    2. Checks for the existance of the 2013 version of mscomctl.ocx and jumps to the right spot if it is there.
    3. Check whether you’re running Windows 32-bit or 64-bit and jumps to the correct command.
    4. Unregisters and then re-registers mscomctl.ocx

    I know that’s a lot of explanation, but this works on multiple versions of Office, whether you have an older version of Windows or not, and it doesn’t require you removing an then re-adding a control.

    Thanks for the space. Hope this helps somebody.

    • TheSmileyCoder says:

      Wow, thank you for this very detailed reply. I’m sure there are many out there that will find it useful.

    • Jim says:

      Tim (or others),
      Newest issue – Windows 10 and Office 2013. I got your fix to work for Win 7 / Office 2013, but any ideas on Windows 10 / Office 2013 – 64 bit. I tried a few things but no luck. The mscomctl.ocx is now in “C:\Program Files\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx”
      Any help would be appreciated…

    • Jim says:

      I tried leaving a comment yesterday, did not show up, try again. Got this to work with Win7 32 and 64 with Office 2013, what about Windows 10? Appears they moved it again. We found the mscomctl.ocx at “C:\Program Files\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx”. I tried Regsvr32 “C:\Program Files\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx” but it isi a 64 bit machine and did not work. Ideas??

    • TheSmileyCoder says:

      Hi Tim
      Your solution saved my sanity today. Thank you for posting that. I had to take care after copy pasting, since the quatationmarks were pasted as a different character, but other than that it worked like a charm.

  11. Jim Janes says:

    Used Tim’s response to get to work on Win 7 32 and 64 with Office 2013. Can’t get to work with Windows 10 – 64 and Office 2013. Found the mscomctl.ocx at “C:\Program Files\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx”. Tried “C:\Program Files\Microsoft Office 15\root\vfs\SystemX86\mscomctl.ocx” did not work. Any ideas???

    • TheSmileyCoder says:

      In short, the MS common control library was written for 32 bit, and is NOT updated for 64 bit (And I don’t believe it will be). This means it will never work for 64 bit office (But can work for 64 bit windows running 32bit office).

      So if you are going to use 64 bit Office, you need to use a different treeview control. Note that even MS recommends going with the 32 bit office.

  12. Brian Scott says:

    I too am having trouble due to Windows 10. I built my database on computers with Windows 8.1 and Windows 7 and Office 2013 and Office 2010. Everything worked fine. However, I upgraded one machine to Windows 10 with Office 2013 and continued work on the database using that machine and everything works great on that machine. However, now the treeview control won’t work on any other computer. I tried to run Tim’s batch file on computer with Windows 8.1 and Office 2013, but it gave an error saying that the file wasn’t found.

    Not sure what to do now.

  13. Ben S. says:

    Thanks to all for the tips and feedback in this blog. I’ll share my recent experience to help others struggling with this.

    I had a Treeview fail to load properly in Access 2013 under Windows Server 2012 (a remote desktop I use for support). I’m opening an MDE created with Access 2010. All the forms work except for the one with the Treeview. When I opened the MDB on this computer the Treeview shows in Design mode but looking in VBA only 5 events are shown. When I look at the Custom properties of the Treeview the dropdowns are blank (like Style, MousePointer, LineStyle, etc.). I created a new form with Treeview and it also showed only 5 events.

    I created the batch file posted by timc512. If you have issues running it I suggest that you add PAUSE commands so you can see the errors. In my case I had to repair double-quotes that got copied and pasted as the special slanted quotes.

    After running the batch file (as Administrator), I went into an MDB and created a new form with a Treeview. All of the events were shown. Also running my old form from the MDB was now working fine.

    Here is where I thought that the solution wasn’t going to work. When I ran the MDE, it still failed. Using the MDB in Access 2013 I created a new MDE and it worked. Unfortunately that is not a good solution because a 2013 MDE will not work in Access 2010, which I need for other users. I thought I was stuck. Then I remembered the universal solution IT. Reboot. I did that and now the MDE created in Access 2010 runs fine on the Windows Server 2012 machine with Access 2013. Whew!

    I made some minor adjustments to the batch file. You can download it here as long as this link is active.
    https://www.dropbox.com/s/4p1oi60kggj2yh4/Register_MSComCtl.bat?dl=0

  14. All solutions above lack on mouse-events. There is a workaround:
    http://www.jkp-ads.com/articles/treeview.asp
    We used it with some necessary modifications like
    Notes.Add => NodeAdd
    mscomctl => clsTreeview
    mscomctl.node => clsNode
    In the MouseEvent functions you have to include a call to your own Event-function
    and some minor changes, but then it works fine.

    • TheSmileyCoder says:

      If the mouse events are missing, then there is still a reference problem, and you need to look at that.

      That said, its definitely worth looking into the treeview control by Jan Karel and others (I have mentioned it previously somewhere). I’ve been playing with it myself some more lately, as I have a project that might end up in 64 bit, which the mscomctl treeview will (To the best of my knowledge) never be able to support.

      Its still missing somethings like rightclick and drag-n-drop which I’ve been looking at possibly implementing. Time will tell.

    • Monkey Coder says:

      This is a very nice alternative. I was going to implement it, however, it also has a reference to an external Microsoft library. If you look carefully they are calling an old Microsoft Forms.dll FM20.dll, thus leaving you with potential problems in the future.

      • TheSmileyCoder says:

        It is my understanding that the FM20 is the same thing driving excel forms. (I have not checked this extensively mind you). If that is the case, then I don’t it going away anytime soon.

  15. dazzerd says:

    Its looking for the mscomctl.ocs file in wow64, just take a copy from its office location and dump it in here:C:\Windows\SysWOW64. The run the batch file as this is where it actually looks for it. I had a problem with a listview and it “Seems” to be working fine now.

  16. I have the Treeview problem on any machine that comes from the manufacturer with two “Microsoft C+++ runtime Libraries Office 2010” showing in the Windows Uninstall dialog. If the user a allows the machine to do Windows Update, then these libraries get updated and my program, FastTrack, fails when the user access a treeview control embedded in my a VB6 program. The problem started in 2012, but MS put out a fix that solved the problem. The fix warned that “this problem may reoccur in future updates” Sure enough, it did early2015 in Windows 8.1. only. The same is also true of Windows 10 AND since Windows 10 won’t allow you to disable upgrades, the user must start Windows without an Internet connection, then uninstall the two libraries, then connect to the Internet and everything is fine.

    Tim’s fix does not solve the problem for me or my customers

  17. Ben S. says:

    Office 365 update 15.0.4779.1002 around 1/15/2015 seems to have brought back issues with MSCOMCTL.OCX and the Treeview. I’ve been working with a user to help repair his machine. We were running a batch file that I had earlier built from tips on this site but forgot to “Run as Administrator”. To reduce some of the pain in the future I added some code to the batch file to have it check to see if it was running as administrator to warn the user. If you’re read this far down the thread you should add this to the top of your batch file.

    @Echo Off
    :: How to check for admin rights
    :: http://superuser.com/questions/204760/batch-script-how-to-check-for-admin-rights
    mkdir “%windir%\system32\test” 2>nul
    if “%errorlevel%” == “0” (
    rmdir “%windir%\system32\test”
    CLS
    Echo Running as Administrator
    ) Else (
    CLS
    Echo.
    Echo For best results you should right-click launch this with “Run as Administrator”.
    Echo.
    Pause
    )
    @Echo On

    ### Note that in todays case running the re-register batch file didn’t fix the problem with Office 365 update 15.0.4779.1002. We eventually found out that another copy of MSCOMCTL.OCX was installed in “C:\Program Files\Microsoft Office 15\root\vfs\SystemX86” and renaming the file resolved the issue. It is odd that Access was reporting that it was referencing the OCX in C:\Windows\SysWOW64, which is also where we were registering it with the batch file. Somehow the version in the SystemX86 folder was causing a conflict and renaming it solved the problem.

    We were able to quickly find all copies of MSCOMCTL on the computer using the free disk search program “Everything” from http://www.voidtools.com. In seconds it located files that were not revealed by Windows Search. “Everything” is a handy utility to have in your toolbox.

  18. Craig Anderson says:

    Hi

    I found this page while searching for a solution to this problem, and have found some great information here.

    The problem I have:

    I have been given the task of maintaining and modifying an access database that was developed by someone else. The database is packaged using SageKey and distributed as an application.

    The tree view issue started when I took over.

    I am working on a clean install of Win 10 (32 bit) and Access 2013.

    The tree view works fine on my computer, but users who use the installer are finding the issue.

    Any advice, or pointers in the right direction would be greatly appreciated.

    Regards

    • TheSmileyCoder says:

      This particular issue can really cause a lot of trouble, and be hard to troubleshoot. I had some recent trouble with the treeview (But oddly enough only in 1 out of 3 apps that all use the treeview). Suddenly people were complaining they couldn’t get it to work. Anyway what I did was:
      A) Open the form in design mode
      B) Delete the treeview control
      C) Press ctrl-Z (Which returns the treeview control)

      Something about the way the undone is performed, seems to reset the treeview.

      Now this “voodoo” solution, I obviously cannot say if it will work for you, but I’d say its worth a try.

      • Craig A says:

        Thanks for your suggestion. I apologise for not replying sooner.

        Unfortunately, the issue remains.

        One of the problems I am having, is that it works fine on my computer. It is others that are having troubles with the install that is built on my computer.

        I am going to completely rebuild the form with the tree view control, and see if that makes any difference.

        • Craig A says:

          If I delete the treeview control, and insert a new one, name it the same as the previous one, is gives me an error that the ImageList needs to be initialised.

          I can’t find any code that initialises the ImageList. How would it have been initialised prior to me deleting it?

          Or is this a glitch?

          • TheSmileyCoder says:

            Hmm, I do remember getting that error once, but not 100% sure what the bug was. In the activeX properties of the treeview, you can select an imagelist. Maybe that is what is missing?

  19. Sam says:

    Just want to say thanks for putting this page up on the www. I proved handy for me when a site I worked with upgraded from Win XP to Win 10 then I had to use MS Access2013 runtime due to some issue and then I discovered my drill down reporting page with treeview control stopped working, That batch file that someone else posted above was great.

  20. Eyad Al-Akhras says:

    Hi,
    On windows 10 64bit, Office 2016 64 bit, I registered the old MSCOMCTL.OCX and referenced it on a module (Showed in References as: Microsoft Windows Common Controls 6.0 (SP6)), but can’t see any of its controls in the “Insert ActiveX Control” dialog box. Yet, I can do this in code: Dim tv as MSComctlLib.TreeView

    But I don’t know a way to reflect this tv variable on my form.

    Help please…

  21. Louis Pienaar says:

    Hi there Anders,

    Thank you so much for this tutorial in Access treeview.

    I used your examples to formulate a treeview access viewer for internal use for me and my colleagues. Unfortunately I’m the only person in our company with Access so I aimed to install Access Runtime on my colleagues computers in order for them to view the same data.

    Unfortunately it doesn’t work on their computers as we get various errors thats got to do with ActiveXControls. The main one where getting says: “The expression MouseMove 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”

    The viewer works perfectly on my computer though

    I use Windows 7 Professional on a 64 bit operating system and have MS Office Professional 2013 32 bit installed.

    My colleagues either have Windows 7 or 10 and MS office 2013 but without Access.

    Can you please help on the issue?

    Regards
    Loui

    • TheSmileyCoder says:

      Most likely they are on a different patched version of the mscomctl library than yourself. This can be a real pain, as the versions are incompatible. Best scenario is to make sure both yourself and the client are updated, and then run the reference fix mentioned here.

  22. Amit Singh says:

    TreeView and Image List control is fine working up to MS Access 2010, but failed to load on MS Access 2013.
    Currently using 64 bit machine and MS Office but fail to see and add in Form TreeView and Image List Control in Activex Control drop down.
    Trying successful to load Mscomctl.ocx in System 32 and SYSwow64 folder.
    But fail to see above control.

1 Pings/Trackbacks for "Got treeview working in Access 2013 again! :)"

Ask a question, leave some feedback, post a reply!