vbavb6vbevbide

Make a VB6- or VBA-IDE environments related reference in IDE Add-In?


I successfully created in VB6 the VB6_IDE_Add_In, that has references to Microsoft "Visual Basic 6.0 Extensibility". However, to use this add-in in VBA IDE (Excel, Access) I obliged to make a copy of VB6_IDE_Add_In project, rename it to VBA_IDE_Add_In, rename its properties etc. and, the main, change mentioned reference to "Microsoft Visual Basic for Applications Extensibility 5.3".

Finally I have two dll - the one for VB6, and the second - for VBA. Both of them I must to "regsvr32" and manually move VBA-IDE-Add-In registry key from VB6 key "[HKCU\Software\Microsoft\Visual Basic\6.0\Addins]" to VBA key [HKCU\Software\Microsoft\VBA\VBE\6.0\Addins]...

Is there a way to compile a single dll that will use right reference accordingly to the VB6 or the VBA environment, using conditional compilation or command line parameter?

Unfortunately, this is my first add-in and my experience is insufficient in this matter...


Solution

  • I doubt you'll be able to compile a single add-in in VB6 for VB6 and VBA, as both libraries share the same name VBIDE and your VB6 project won't allow two references with the same name. MZTools 3.0, when it was written in VB6, used to publish a version for VB5 (which uses yet another, earlier version of VB extensibility library), VB6 and VBA. Since the release of MZ Tools Version 8, the source has been migrated to .NET, and it is much easier to support multiple environments and 32-bit/64-bit versions of VB/VBA hosts.

    You would be wise to follow the lead, and develop a solution using .NET. A .NET solution like MZ Tools, or Rubberduck VBA, can be used by 32-bit and 64-bit hosts, and by creating your own Interop Assemblies (and embedding their types) from the VBIDE type libraries, you can create a single dll for VB5, VB6 and VBA.

    Rubberduck VBA hasn't yet added support for VB6, but we're working on it:

    Shared VB6 and VBA extensibility add-in with OnConnect and OnDisconnect handling