Within an application I’m developing for Excel (version doesn’t matter) I use the Microsoft Common Dialog Control, version 6 (SP6), contained in COMDLG32.OCX. For some reason I did not want to put the control on a UserForm and I decided to use it with late binding in my code.
So far so good, the application ran like a charm, and everyone in my office environment was happy with it.
However, when we started distributing the application to other people, it all of a sudden stopped working and the common dialog never popped up and of course, nobody could save or open files.
After investigation, I found out that this statement didn’t work:
Dim cDlg As Object Set cDlg = VBA.CreateObject("MSComDlg.CommonDialog")
To my surprise, I got a run-time error 429 stating ActiveX component can’t create object. First I thought it was missing but this was not the case (you will find it on every PC). I tried to re-register the component but without success.
In short, and after a lot of googling, I found out that on the failing PC there wasn’t a problem with the component but with the permissions of this component. This particular component can be used in a custom application only if properly licensed and Microsoft provides the license for this component only if you are running a developer’s version of Office or of Visual Studio (and indeed in my office all PCs have). Of course, installing such edition together with my application or asking my customers to buy one was not an option for me and I had to find another solution.
Although Microsoft caused me trouble but they also provided me with a solution.
It turns out that these “component-licenses” are stored in the Registry, in particularly under the key named HKCR\Licenses. Each licensed component has its own sub-key —unfortunately with no correspondence with the CLSID of the component— and a license string stored in the (Default) item.
After some trial-and-error I was able to isolate the key used by the Common Dialog (see below) and after adding it to the PC where my application was failing I finally got everything working again, making me a happy camper.
To add the license information for the Common Dialog copy the next section to a text file, save it with a “.REG” extension and merge it into the Registry (I do this via InnoSetup):
Windows Registry Editor Version 5.00
@="Licensing: Copying the keys may be a violation of established copyrights."
I must remind that messing with the Registry can cause trouble and that creating entries under the “Licenses” key may be a violation of established copyrights, and for that purpose I have added the first line in the above text (copied from my PC’s registry).