In an Excel 2003 VBA project I am using controls from MSCOMCTL.OCX. That is the VBA project has a reference to System32\MSCOMCTL.OCX.
When I open that project in Excel 2003 on my 64-bit Windows 7 system, Excel automatically changes the reference to SysWOW64\MSCOMCTL.OCX (which is the correct location).
However, when I send that project to my client who is using 32-bit Windows XP, the project complains during opening because SysWOW64\MSCOMCTL.OCX does not exist on his system.
Here are the (unsatisfactory) solutions I came up with so far:
Instruct the client to manually change the reference back to the correct location on his system (System32\MSCOMCTL.OCX).
- This does not really work for the following reasons:
- When Excel 2003 32-bit opens the sheet and it cannot find the reference to MSCOMCTL, it removes all the controls that came from the library (e. g. TreeCtrl) from the forms :-(
- Client is struggling with the procedure and it is quite cumbersome for him.
- This does not really work for the following reasons:
- Automatically correct the reference using VBA's VBProject.References.AddFromFile/AddFromGuid.
- Same problem as above: When compilation of VBA during opening of workbook fails, Excel will remove all controls that it could not find from the forms.
- Automatically add the reference (as in 2.) and use dynamic binding to add all the relevant controls during runtime.
- This could actually work, however currently I am struggling with binding the event handlers to the controls (but that will be separate question ;-)
Approaches 1. and 2. do not really solve anything and solution 3 is a lot of work.
Any ideas would be greatly appreciated.